prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Type refactoring has a regression with inheritance and explicit fields.
  ```python
  @strawberry.input
  class A:
      a: str = strawberry.field(default='', desc='')
  
  @strawberry.input
  class B(A):
      b: Optional[str] = strawberry.field(default=None, desc='')
  
  @strawberry.type
  class Query:
      @strawberry.field
      def field(self, arg: B) -> str:
          return ''
  
  schema = strawberry.Schema(query=Query)
  result = schema.execute_sync('{ field(arg: {}) }')
  assert not result.errors
  ```
  raises `TypeError: B fields cannot be resolved. unhashable type: 'StrawberryAnnotation'`.
  
  `StrawberryAnnotation` has a custom `__eq__` without a `__hash__`, causing a set lookup to fail. However adding a suitable `__hash__` just lead to the next `TypeError`.
  
  `StrawberryOptional` likely has the same problem.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `strawberry/types/type_resolver.py`
  Content:
  ```
  1 import dataclasses
  2 import sys
  3 from typing import Dict, List, Type
  4 
  5 from strawberry.annotation import StrawberryAnnotation
  6 from strawberry.exceptions import (
  7     FieldWithResolverAndDefaultFactoryError,
  8     FieldWithResolverAndDefaultValueError,
  9     PrivateStrawberryFieldError,
  10 )
  11 from strawberry.field import StrawberryField
  12 from strawberry.private import Private
  13 from strawberry.utils.str_converters import to_camel_case
  14 
  15 from ..arguments import UNSET
  16 
  17 
  18 def _get_fields(cls: Type) -> List[StrawberryField]:
  19     """Get all the strawberry fields off a strawberry.type cls
  20 
  21     This function returns a list of StrawberryFields (one for each field item), while
  22     also paying attention the name and typing of the field.
  23 
  24     StrawberryFields can be defined on a strawberry.type class as either a dataclass-
  25     style field or using strawberry.field as a decorator.
  26 
  27     >>> import strawberry
  28     >>> @strawberry.type
  29     ... class Query:
  30     ...     type_1a: int = 5
  31     ...     type_1b: int = strawberry.field(...)
  32     ...     type_1c: int = strawberry.field(resolver=...)
  33     ...
  34     ...     @strawberry.field
  35     ...     def type_2(self) -> int:
  36     ...         ...
  37 
  38     Type #1:
  39         A pure dataclass-style field. Will not have a StrawberryField; one will need to
  40         be created in this function. Type annotation is required.
  41 
  42     Type #2:
  43         A field defined using @strawberry.field as a decorator around the resolver. The
  44         resolver must be type-annotated.
  45 
  46     The StrawberryField.python_name value will be assigned to the field's name on the
  47     class if one is not set by either using an explicit strawberry.field(name=...) or by
  48     passing a named function (i.e. not an anonymous lambda) to strawberry.field
  49     (typically as a decorator).
  50     """
  51     # Deferred import to avoid import cycles
  52     from strawberry.field import StrawberryField
  53 
  54     fields: Dict[str, StrawberryField] = {}
  55 
  56     # before trying to find any fields, let's first add the fields defined in
  57     # parent classes, we do this by checking if parents have a type definition
  58     for base in cls.__bases__:
  59         if hasattr(base, "_type_definition"):
  60             base_fields = {
  61                 field.graphql_name: field
  62                 # TODO: we need to rename _fields to something else
  63                 for field in base._type_definition._fields  # type: ignore
  64             }
  65 
  66             # Add base's fields to cls' fields
  67             fields = {**fields, **base_fields}
  68 
  69     # then we can proceed with finding the fields for the current class
  70     for field in dataclasses.fields(cls):
  71 
  72         if isinstance(field, StrawberryField):
  73             # Check that the field type is not Private
  74             if isinstance(field.type, Private):
  75                 raise PrivateStrawberryFieldError(field.python_name, cls.__name__)
  76 
  77             # Check that default is not set if a resolver is defined
  78             if field.default != dataclasses.MISSING and field.base_resolver is not None:
  79                 raise FieldWithResolverAndDefaultValueError(
  80                     field.python_name, cls.__name__
  81                 )
  82 
  83             # Check that default_factory is not set if a resolver is defined
  84             # Note: using getattr because of this issue:
  85             # https://github.com/python/mypy/issues/6910
  86             if (
  87                 getattr(field, "default_factory") != dataclasses.MISSING  # noqa
  88                 and field.base_resolver is not None
  89             ):
  90                 raise FieldWithResolverAndDefaultFactoryError(
  91                     field.python_name, cls.__name__
  92                 )
  93 
  94             # we make sure that the origin is either the field's resolver when
  95             # called as:
  96             #
  97             # >>> @strawberry.field
  98             # ... def x(self): ...
  99             #
  100             # or the class where this field was defined, so we always have
  101             # the correct origin for determining field types when resolving
  102             # the types.
  103             field.origin = field.origin or cls
  104 
  105             # Make sure types are StrawberryAnnotations
  106             if not isinstance(field.type, StrawberryAnnotation):
  107                 module = sys.modules[field.origin.__module__]
  108                 field.type_annotation = StrawberryAnnotation(
  109                     annotation=field.type_annotation, namespace=module.__dict__
  110                 )
  111 
  112         # Create a StrawberryField for fields that didn't use strawberry.field
  113         else:
  114             # Only ignore Private fields that weren't defined using StrawberryFields
  115             if isinstance(field.type, Private):
  116                 continue
  117 
  118             field_type = field.type
  119 
  120             module = sys.modules[cls.__module__]
  121 
  122             # Create a StrawberryField, for fields of Types #1 and #2a
  123             field = StrawberryField(
  124                 python_name=field.name,
  125                 graphql_name=to_camel_case(field.name),
  126                 type_annotation=StrawberryAnnotation(
  127                     annotation=field_type,
  128                     namespace=module.__dict__,
  129                 ),
  130                 origin=cls,
  131                 default=getattr(cls, field.name, UNSET),
  132             )
  133 
  134         field_name = field.graphql_name
  135 
  136         assert_message = "Field must have a name by the time the schema is generated"
  137         assert field_name is not None, assert_message
  138 
  139         # TODO: Raise exception if field_name already in fields
  140         fields[field_name] = field
  141 
  142     return list(fields.values())
  143
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/strawberry/types/type_resolver.py b/strawberry/types/type_resolver.py
  --- a/strawberry/types/type_resolver.py
  +++ b/strawberry/types/type_resolver.py
  @@ -103,7 +103,7 @@
               field.origin = field.origin or cls
   
               # Make sure types are StrawberryAnnotations
  -            if not isinstance(field.type, StrawberryAnnotation):
  +            if not isinstance(field.type_annotation, StrawberryAnnotation):
                   module = sys.modules[field.origin.__module__]
                   field.type_annotation = StrawberryAnnotation(
                       annotation=field.type_annotation, namespace=module.__dict__
  
verification_info: {"golden_diff": "diff --git a/strawberry/types/type_resolver.py b/strawberry/types/type_resolver.py\n--- a/strawberry/types/type_resolver.py\n+++ b/strawberry/types/type_resolver.py\n@@ -103,7 +103,7 @@\n             field.origin = field.origin or cls\n \n             # Make sure types are StrawberryAnnotations\n-            if not isinstance(field.type, StrawberryAnnotation):\n+            if not isinstance(field.type_annotation, StrawberryAnnotation):\n                 module = sys.modules[field.origin.__module__]\n                 field.type_annotation = StrawberryAnnotation(\n                     annotation=field.type_annotation, namespace=module.__dict__\n", "issue": "Type refactoring has a regression with inheritance and explicit fields.\n```python\r\n@strawberry.input\r\nclass A:\r\n    a: str = strawberry.field(default='', desc='')\r\n\r\n@strawberry.input\r\nclass B(A):\r\n    b: Optional[str] = strawberry.field(default=None, desc='')\r\n\r\n@strawberry.type\r\nclass Query:\r\n    @strawberry.field\r\n    def field(self, arg: B) -> str:\r\n        return ''\r\n\r\nschema = strawberry.Schema(query=Query)\r\nresult = schema.execute_sync('{ field(arg: {}) }')\r\nassert not result.errors\r\n```\r\nraises `TypeError: B fields cannot be resolved. unhashable type: 'StrawberryAnnotation'`.\r\n\r\n`StrawberryAnnotation` has a custom `__eq__` without a `__hash__`, causing a set lookup to fail. However adding a suitable `__hash__` just lead to the next `TypeError`.\r\n\r\n`StrawberryOptional` likely has the same problem.\r\n\n", "before_files": [{"content": "import dataclasses\nimport sys\nfrom typing import Dict, List, Type\n\nfrom strawberry.annotation import StrawberryAnnotation\nfrom strawberry.exceptions import (\n    FieldWithResolverAndDefaultFactoryError,\n    FieldWithResolverAndDefaultValueError,\n    PrivateStrawberryFieldError,\n)\nfrom strawberry.field import StrawberryField\nfrom strawberry.private import Private\nfrom strawberry.utils.str_converters import to_camel_case\n\nfrom ..arguments import UNSET\n\n\ndef _get_fields(cls: Type) -> List[StrawberryField]:\n    \"\"\"Get all the strawberry fields off a strawberry.type cls\n\n    This function returns a list of StrawberryFields (one for each field item), while\n    also paying attention the name and typing of the field.\n\n    StrawberryFields can be defined on a strawberry.type class as either a dataclass-\n    style field or using strawberry.field as a decorator.\n\n    >>> import strawberry\n    >>> @strawberry.type\n    ... class Query:\n    ...     type_1a: int = 5\n    ...     type_1b: int = strawberry.field(...)\n    ...     type_1c: int = strawberry.field(resolver=...)\n    ...\n    ...     @strawberry.field\n    ...     def type_2(self) -> int:\n    ...         ...\n\n    Type #1:\n        A pure dataclass-style field. Will not have a StrawberryField; one will need to\n        be created in this function. Type annotation is required.\n\n    Type #2:\n        A field defined using @strawberry.field as a decorator around the resolver. The\n        resolver must be type-annotated.\n\n    The StrawberryField.python_name value will be assigned to the field's name on the\n    class if one is not set by either using an explicit strawberry.field(name=...) or by\n    passing a named function (i.e. not an anonymous lambda) to strawberry.field\n    (typically as a decorator).\n    \"\"\"\n    # Deferred import to avoid import cycles\n    from strawberry.field import StrawberryField\n\n    fields: Dict[str, StrawberryField] = {}\n\n    # before trying to find any fields, let's first add the fields defined in\n    # parent classes, we do this by checking if parents have a type definition\n    for base in cls.__bases__:\n        if hasattr(base, \"_type_definition\"):\n            base_fields = {\n                field.graphql_name: field\n                # TODO: we need to rename _fields to something else\n                for field in base._type_definition._fields  # type: ignore\n            }\n\n            # Add base's fields to cls' fields\n            fields = {**fields, **base_fields}\n\n    # then we can proceed with finding the fields for the current class\n    for field in dataclasses.fields(cls):\n\n        if isinstance(field, StrawberryField):\n            # Check that the field type is not Private\n            if isinstance(field.type, Private):\n                raise PrivateStrawberryFieldError(field.python_name, cls.__name__)\n\n            # Check that default is not set if a resolver is defined\n            if field.default != dataclasses.MISSING and field.base_resolver is not None:\n                raise FieldWithResolverAndDefaultValueError(\n                    field.python_name, cls.__name__\n                )\n\n            # Check that default_factory is not set if a resolver is defined\n            # Note: using getattr because of this issue:\n            # https://github.com/python/mypy/issues/6910\n            if (\n                getattr(field, \"default_factory\") != dataclasses.MISSING  # noqa\n                and field.base_resolver is not None\n            ):\n                raise FieldWithResolverAndDefaultFactoryError(\n                    field.python_name, cls.__name__\n                )\n\n            # we make sure that the origin is either the field's resolver when\n            # called as:\n            #\n            # >>> @strawberry.field\n            # ... def x(self): ...\n            #\n            # or the class where this field was defined, so we always have\n            # the correct origin for determining field types when resolving\n            # the types.\n            field.origin = field.origin or cls\n\n            # Make sure types are StrawberryAnnotations\n            if not isinstance(field.type, StrawberryAnnotation):\n                module = sys.modules[field.origin.__module__]\n                field.type_annotation = StrawberryAnnotation(\n                    annotation=field.type_annotation, namespace=module.__dict__\n                )\n\n        # Create a StrawberryField for fields that didn't use strawberry.field\n        else:\n            # Only ignore Private fields that weren't defined using StrawberryFields\n            if isinstance(field.type, Private):\n                continue\n\n            field_type = field.type\n\n            module = sys.modules[cls.__module__]\n\n            # Create a StrawberryField, for fields of Types #1 and #2a\n            field = StrawberryField(\n                python_name=field.name,\n                graphql_name=to_camel_case(field.name),\n                type_annotation=StrawberryAnnotation(\n                    annotation=field_type,\n                    namespace=module.__dict__,\n                ),\n                origin=cls,\n                default=getattr(cls, field.name, UNSET),\n            )\n\n        field_name = field.graphql_name\n\n        assert_message = \"Field must have a name by the time the schema is generated\"\n        assert field_name is not None, assert_message\n\n        # TODO: Raise exception if field_name already in fields\n        fields[field_name] = field\n\n    return list(fields.values())\n", "path": "strawberry/types/type_resolver.py"}], "after_files": [{"content": "import dataclasses\nimport sys\nfrom typing import Dict, List, Type\n\nfrom strawberry.annotation import StrawberryAnnotation\nfrom strawberry.exceptions import (\n    FieldWithResolverAndDefaultFactoryError,\n    FieldWithResolverAndDefaultValueError,\n    PrivateStrawberryFieldError,\n)\nfrom strawberry.field import StrawberryField\nfrom strawberry.private import Private\nfrom strawberry.utils.str_converters import to_camel_case\n\nfrom ..arguments import UNSET\n\n\ndef _get_fields(cls: Type) -> List[StrawberryField]:\n    \"\"\"Get all the strawberry fields off a strawberry.type cls\n\n    This function returns a list of StrawberryFields (one for each field item), while\n    also paying attention the name and typing of the field.\n\n    StrawberryFields can be defined on a strawberry.type class as either a dataclass-\n    style field or using strawberry.field as a decorator.\n\n    >>> import strawberry\n    >>> @strawberry.type\n    ... class Query:\n    ...     type_1a: int = 5\n    ...     type_1b: int = strawberry.field(...)\n    ...     type_1c: int = strawberry.field(resolver=...)\n    ...\n    ...     @strawberry.field\n    ...     def type_2(self) -> int:\n    ...         ...\n\n    Type #1:\n        A pure dataclass-style field. Will not have a StrawberryField; one will need to\n        be created in this function. Type annotation is required.\n\n    Type #2:\n        A field defined using @strawberry.field as a decorator around the resolver. The\n        resolver must be type-annotated.\n\n    The StrawberryField.python_name value will be assigned to the field's name on the\n    class if one is not set by either using an explicit strawberry.field(name=...) or by\n    passing a named function (i.e. not an anonymous lambda) to strawberry.field\n    (typically as a decorator).\n    \"\"\"\n    # Deferred import to avoid import cycles\n    from strawberry.field import StrawberryField\n\n    fields: Dict[str, StrawberryField] = {}\n\n    # before trying to find any fields, let's first add the fields defined in\n    # parent classes, we do this by checking if parents have a type definition\n    for base in cls.__bases__:\n        if hasattr(base, \"_type_definition\"):\n            base_fields = {\n                field.graphql_name: field\n                # TODO: we need to rename _fields to something else\n                for field in base._type_definition._fields  # type: ignore\n            }\n\n            # Add base's fields to cls' fields\n            fields = {**fields, **base_fields}\n\n    # then we can proceed with finding the fields for the current class\n    for field in dataclasses.fields(cls):\n\n        if isinstance(field, StrawberryField):\n            # Check that the field type is not Private\n            if isinstance(field.type, Private):\n                raise PrivateStrawberryFieldError(field.python_name, cls.__name__)\n\n            # Check that default is not set if a resolver is defined\n            if field.default != dataclasses.MISSING and field.base_resolver is not None:\n                raise FieldWithResolverAndDefaultValueError(\n                    field.python_name, cls.__name__\n                )\n\n            # Check that default_factory is not set if a resolver is defined\n            # Note: using getattr because of this issue:\n            # https://github.com/python/mypy/issues/6910\n            if (\n                getattr(field, \"default_factory\") != dataclasses.MISSING  # noqa\n                and field.base_resolver is not None\n            ):\n                raise FieldWithResolverAndDefaultFactoryError(\n                    field.python_name, cls.__name__\n                )\n\n            # we make sure that the origin is either the field's resolver when\n            # called as:\n            #\n            # >>> @strawberry.field\n            # ... def x(self): ...\n            #\n            # or the class where this field was defined, so we always have\n            # the correct origin for determining field types when resolving\n            # the types.\n            field.origin = field.origin or cls\n\n            # Make sure types are StrawberryAnnotations\n            if not isinstance(field.type_annotation, StrawberryAnnotation):\n                module = sys.modules[field.origin.__module__]\n                field.type_annotation = StrawberryAnnotation(\n                    annotation=field.type_annotation, namespace=module.__dict__\n                )\n\n        # Create a StrawberryField for fields that didn't use strawberry.field\n        else:\n            # Only ignore Private fields that weren't defined using StrawberryFields\n            if isinstance(field.type, Private):\n                continue\n\n            field_type = field.type\n\n            module = sys.modules[cls.__module__]\n\n            # Create a StrawberryField, for fields of Types #1 and #2a\n            field = StrawberryField(\n                python_name=field.name,\n                graphql_name=to_camel_case(field.name),\n                type_annotation=StrawberryAnnotation(\n                    annotation=field_type,\n                    namespace=module.__dict__,\n                ),\n                origin=cls,\n                default=getattr(cls, field.name, UNSET),\n            )\n\n        field_name = field.graphql_name\n\n        assert_message = \"Field must have a name by the time the schema is generated\"\n        assert field_name is not None, assert_message\n\n        # TODO: Raise exception if field_name already in fields\n        fields[field_name] = field\n\n    return list(fields.values())\n", "path": "strawberry/types/type_resolver.py"}]}