internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: strawberry-graphql/strawberry

Issue:
from_pydantic() converts False values to None
When calling `from_pydantic()`, values consistent with `bool(value) == False` may be replaced with None. 

This recreates the issue:
```
from pydantic import BaseModel
import strawberry

class PydanticClass(BaseModel):
    str1: str
    str2: str
    bool1: bool
    bool2: bool

@strawberry.experimental.pydantic.type(
    model=PydanticClass,
    fields=['str1', 'str2', 'bool1', 'bool2']
)
class StrawberryClass:
    pass

str1 = 'nonempty'
str2 = ''
bool1 = True
bool2 = False

myobj = PydanticClass(
    str1=str1,
    str2=str2,
    bool1=bool1,
    bool2=bool2
)
print('pydantic obj:', myobj)

converted = StrawberryClass.from_pydantic(myobj)
print('converted:', converted)
```

The output:
```
pydantic obj: str1='nonempty' str2='' bool1=True bool2=False
converted obj: StrawberryClass(str1='nonempty', str2=None, bool1=True, bool2=None)
```
Both str2 and bool2 were converted to None.

Location of the bug: https://github.com/strawberry-graphql/strawberry/blob/main/strawberry/experimental/pydantic/conversion.py#L10




Discussion:

Resolving patch:
diff --git a/strawberry/experimental/pydantic/conversion.py b/strawberry/experimental/pydantic/conversion.py
--- a/strawberry/experimental/pydantic/conversion.py
+++ b/strawberry/experimental/pydantic/conversion.py
@@ -7,7 +7,7 @@
 def _convert_from_pydantic_to_strawberry_field(
     field: StrawberryField, data_from_model=None, extra=None
 ):
-    data = data_from_model or extra
+    data = data_from_model if data_from_model is not None else extra
 
     if field.is_list:
         assert field.child is not None


Test patch:
diff --git a/tests/experimental/pydantic/test_conversion.py b/tests/experimental/pydantic/test_conversion.py
--- a/tests/experimental/pydantic/test_conversion.py
+++ b/tests/experimental/pydantic/test_conversion.py
@@ -52,6 +52,22 @@ class User:
     assert user.password == "abc"
 
 
+def test_can_covert_falsy_values_to_strawberry():
+    class UserModel(pydantic.BaseModel):
+        age: int
+        password: str
+
+    @strawberry.experimental.pydantic.type(UserModel, fields=["age", "password"])
+    class User:
+        pass
+
+    origin_user = UserModel(age=0, password="")
+    user = User.from_pydantic(origin_user)
+
+    assert user.age == 0
+    assert user.password == ""
+
+
 def test_can_covert_pydantic_type_with_nested_data_to_strawberry():
     class WorkModel(pydantic.BaseModel):
         name: str
Repository: strawberry-graphql/strawberry

Issue:
Bug: Failure when returning List[List[int]] as a strawberry type in a query
The follow code doesn't run

strawberry server schema
Then running a graphiql query is sufficient to reproduce this error.

error message TypeError: 'float' object is not iterable

```python
@strawberry.type(description="list of list breaks it")
class Polygon:
    polygon_of_death: typing.List[typing.List[float]]


def get_polygon() -> Polygon:
    not_polygon_of_death = Polygon([])
    polygon_of_death = Polygon(polygon_of_death=[[2.0,6.0]])
    return polygon_of_death


@strawberry.type(description="This is the root level query description")
class Query:
    get_polygons: Polygon = strawberry.field(resolver=get_polygon)


schema = strawberry.Schema(query=Query)

```




Discussion:
Thanks for the report! will take a look 😊 

Resolving patch:
diff --git a/strawberry/field.py b/strawberry/field.py
--- a/strawberry/field.py
+++ b/strawberry/field.py
@@ -238,8 +238,8 @@ def _convert_enums_to_values(field_: StrawberryField, result: Any) -> Any:
                 return result.value
 
             if field_.is_list:
-                assert self.child is not None
-                return [_convert_enums_to_values(self.child, item) for item in result]
+                assert field_.child is not None
+                return [_convert_enums_to_values(field_.child, item) for item in result]
 
             return result
 


Test patch:
diff --git a/tests/schema/test_list.py b/tests/schema/test_list.py
--- a/tests/schema/test_list.py
+++ b/tests/schema/test_list.py
@@ -35,3 +35,21 @@ def example(self) -> List[Optional[str]]:
 
     assert not result.errors
     assert result.data["example"] == ["Example", None]
+
+
+def test_lists_of_lists():
+    def get_polygons() -> List[List[float]]:
+        return [[2.0, 6.0]]
+
+    @strawberry.type
+    class Query:
+        polygons: List[List[float]] = strawberry.field(resolver=get_polygons)
+
+    schema = strawberry.Schema(query=Query)
+
+    query = "{ polygons }"
+
+    result = schema.execute_sync(query, root_value=Query())
+
+    assert not result.errors
+    assert result.data["polygons"] == [[2.0, 6.0]]
Repository: strawberry-graphql/strawberry

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.



Discussion:
Looks like the missing `__hash__` function was just a symptom (although may be working fixing anyway).

The root cause is `StrawberryAnnotation` being called on its own instances.

Resolving patch:
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 @@ class if one is not set by either using an explicit strawberry.field(name=...) o
             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__


Test patch:
diff --git a/tests/objects/test_inheritance.py b/tests/objects/test_inheritance.py
new file mode 100644
--- /dev/null
+++ b/tests/objects/test_inheritance.py
@@ -0,0 +1,15 @@
+from typing import Optional
+
+import strawberry
+
+
+def test_inherited_fields():
+    @strawberry.type
+    class A:
+        a: str = strawberry.field(default="")
+
+    @strawberry.type
+    class B(A):
+        b: Optional[str] = strawberry.field(default=None)
+
+    assert strawberry.Schema(query=B)
Repository: strawberry-graphql/strawberry

Issue:
The export-schema command fails when trying to import local modules



Discussion:

Resolving patch:
diff --git a/strawberry/cli/commands/export_schema.py b/strawberry/cli/commands/export_schema.py
--- a/strawberry/cli/commands/export_schema.py
+++ b/strawberry/cli/commands/export_schema.py
@@ -1,3 +1,5 @@
+import sys
+
 import click
 
 from strawberry import Schema
@@ -7,7 +9,20 @@
 
 @click.command(short_help="Exports the schema")
 @click.argument("schema", type=str)
-def export_schema(schema: str):
+@click.option(
+    "--app-dir",
+    default=".",
+    type=str,
+    show_default=True,
+    help=(
+        "Look for the module in the specified directory, by adding this to the "
+        "PYTHONPATH. Defaults to the current working directory. "
+        "Works the same as `--app-dir` in uvicorn."
+    ),
+)
+def export_schema(schema: str, app_dir):
+    sys.path.insert(0, app_dir)
+
     try:
         schema_symbol = import_module_symbol(schema, default_symbol_name="schema")
     except (ImportError, AttributeError) as exc:


Test patch:
diff --git a/tests/cli/test_export_schema.py b/tests/cli/test_export_schema.py
--- a/tests/cli/test_export_schema.py
+++ b/tests/cli/test_export_schema.py
@@ -25,6 +25,15 @@ def test_default_schema_symbol_name(cli_runner):
     assert result.exit_code == 0
 
 
+def test_app_dir_option(cli_runner):
+    selector = "sample_module"
+    result = cli_runner.invoke(
+        cmd_export_schema, ["--app-dir=./tests/fixtures/sample_package", selector]
+    )
+
+    assert result.exit_code == 0
+
+
 def test_invalid_module(cli_runner):
     selector = "not.existing.module"
     result = cli_runner.invoke(cmd_export_schema, [selector])
Repository: strawberry-graphql/strawberry

Issue:
`merge_type` `types` type hint
https://github.com/strawberry-graphql/strawberry/blob/main/strawberry/tools/merge_types.py#L9

The current `Tuple[Type]` produces:
```
*.py:15:5: error: Argument 2 to "merge_types" has incompatible type "Tuple[Type[QueryA], Type[QueryB], Type[QueryC]]"; expected "Tuple[Type[Any]]"  [arg-type]
```

According to [mypy](https://mypy.readthedocs.io/en/stable/kinds_of_types.html#tuple-types), we should either change it to `Tuple[Type, ...]` or follow mypy's suggestion and go with a generic `Sequence`.




Discussion:

Resolving patch:
diff --git a/strawberry/tools/merge_types.py b/strawberry/tools/merge_types.py
--- a/strawberry/tools/merge_types.py
+++ b/strawberry/tools/merge_types.py
@@ -1,12 +1,12 @@
 import warnings
 from collections import Counter
 from itertools import chain
-from typing import Tuple, Type
+from typing import Tuple
 
 import strawberry
 
 
-def merge_types(name: str, types: Tuple[Type]) -> Type:
+def merge_types(name: str, types: Tuple[type, ...]) -> type:
     """Merge multiple Strawberry types into one
 
     For example, given two queries `A` and `B`, one can merge them into a
@@ -23,7 +23,9 @@ class SuperQuery(B, A):
     if not types:
         raise ValueError("Can't merge types if none are supplied")
 
-    fields = chain(*(t._type_definition.fields for t in types))
+    fields = chain(
+        *(t._type_definition.fields for t in types)  # type: ignore[attr-defined]
+    )
     counter = Counter(f.name for f in fields)
     dupes = [f for f, c in counter.most_common() if c > 1]
     if dupes:


Test patch:
diff --git a/tests/mypy/test_merge_types.yml b/tests/mypy/test_merge_types.yml
new file mode 100644
--- /dev/null
+++ b/tests/mypy/test_merge_types.yml
@@ -0,0 +1,18 @@
+- case: test_merge_types
+  main: |
+    import strawberry
+    from strawberry.tools import merge_types
+
+    @strawberry.type
+    class QueryA:
+        field1: str
+
+    @strawberry.type
+    class QueryB:
+        field2: int
+
+    Query = merge_types("AwesomeQuery", (QueryA, QueryB))
+
+    reveal_type(Query)
+  out: |
+    main:14: note: Revealed type is "builtins.type"
Repository: strawberry-graphql/strawberry

Issue:
StrawberryResolver.annotation removed in release 0.115.0
I, and possibly others, am relying on the annotations of the resolver in order to "inherit" resolvers.
It would be great if we could have that information returned in a future release.  


Discussion:

Resolving patch:
diff --git a/strawberry/types/fields/resolver.py b/strawberry/types/fields/resolver.py
--- a/strawberry/types/fields/resolver.py
+++ b/strawberry/types/fields/resolver.py
@@ -213,6 +213,25 @@ def name(self) -> str:
         # TODO: What to do if resolver is a lambda?
         return self._unbound_wrapped_func.__name__
 
+    @cached_property
+    def annotations(self) -> Dict[str, object]:
+        """Annotations for the resolver.
+
+        Does not include special args defined in `RESERVED_PARAMSPEC` (e.g. self, root,
+        info)
+        """
+        reserved_parameters = self.reserved_parameters
+        reserved_names = {p.name for p in reserved_parameters.values() if p is not None}
+
+        annotations = self._unbound_wrapped_func.__annotations__
+        annotations = {
+            name: annotation
+            for name, annotation in annotations.items()
+            if name not in reserved_names
+        }
+
+        return annotations
+
     @cached_property
     def type_annotation(self) -> Optional[StrawberryAnnotation]:
         return_annotation = self.signature.return_annotation


Test patch:
diff --git a/tests/fields/test_resolvers.py b/tests/fields/test_resolvers.py
--- a/tests/fields/test_resolvers.py
+++ b/tests/fields/test_resolvers.py
@@ -11,6 +11,7 @@
     MissingReturnAnnotationError,
 )
 from strawberry.types.fields.resolver import StrawberryResolver, UncallableResolverError
+from strawberry.types.info import Info
 
 
 def test_resolver_as_argument():
@@ -260,3 +261,26 @@ def name(self) -> str:
 
     assert Query(1) == Query(1)
     assert Query(1) != Query(2)
+
+
+def test_resolver_annotations():
+    """Ensure only non-reserved annotations are returned."""
+
+    def resolver_annotated_info(
+        self, root, foo: str, bar: float, info: str, strawberry_info: Info
+    ) -> str:
+        return "Hello world"
+
+    resolver = StrawberryResolver(resolver_annotated_info)
+
+    expected_annotations = {"foo": str, "bar": float, "info": str, "return": str}
+    assert resolver.annotations == expected_annotations
+
+    # Sanity-check to ensure StrawberryArguments return the same annotations
+    assert {
+        **{
+            arg.python_name: arg.type_annotation.resolve()  # type: ignore
+            for arg in resolver.arguments
+        },
+        "return": str,
+    }
Repository: strawberry-graphql/strawberry

Issue:
Postponed annotation evaluation causes `Annotated` to break
When using postponed annotation evaluation, annotating resolver arguments no longer works:

```python
from __future__ import annotations

import random
from typing import Annotated

import strawberry


@strawberry.type
class Query:
    @strawberry.field
    def dice_roll(
        self,
        sides: Annotated[
            int,
            strawberry.argument(description="Number of sides the die should have."),
        ] = 6,
    ) -> int:
        return random.randint(1, sides)


strawberry.Schema(query=Query)
```

The example above raises this TypeError:

```
TypeError: Query fields cannot be resolved. Unexpected type 'typing.Annotated[int, <strawberry.arguments.StrawberryArgumentAnnotation object at 0x7fd12e130d00>]'
```

When the first line (`from __future__ import annotations`) is left out, everything works as intended. This will probably also break once Python 3.11 lands, since the behavior will become mandatory then. #1586 refers to a somewhat related issue.


Discussion:

Resolving patch:
diff --git a/strawberry/auto.py b/strawberry/auto.py
--- a/strawberry/auto.py
+++ b/strawberry/auto.py
@@ -57,7 +57,7 @@ def __instancecheck__(
             if args[0] is Any:
                 return any(isinstance(arg, StrawberryAuto) for arg in args[1:])
 
-        return False
+        return instance == "strawberry.auto"
 
 
 class StrawberryAuto(metaclass=StrawberryAutoMeta):


Test patch:
diff --git a/tests/experimental/pydantic/schema/test_forward_reference.py b/tests/experimental/pydantic/schema/test_forward_reference.py
new file mode 100644
--- /dev/null
+++ b/tests/experimental/pydantic/schema/test_forward_reference.py
@@ -0,0 +1,50 @@
+from __future__ import annotations
+
+import textwrap
+from typing import Optional
+
+import pydantic
+
+import strawberry
+
+
+def test_auto_fields():
+    global User
+
+    class UserModel(pydantic.BaseModel):
+        age: int
+        password: Optional[str]
+        other: float
+
+    @strawberry.experimental.pydantic.type(UserModel)
+    class User:
+        age: strawberry.auto
+        password: strawberry.auto
+
+    @strawberry.type
+    class Query:
+        @strawberry.field
+        def user(self) -> User:
+            return User(age=1, password="ABC")
+
+    schema = strawberry.Schema(query=Query)
+
+    expected_schema = """
+    type Query {
+      user: User!
+    }
+
+    type User {
+      age: Int!
+      password: String
+    }
+    """
+
+    assert str(schema) == textwrap.dedent(expected_schema).strip()
+
+    query = "{ user { age } }"
+
+    result = schema.execute_sync(query)
+
+    assert not result.errors
+    assert result.data["user"]["age"] == 1
Repository: strawberry-graphql/strawberry

Issue:
Move non-core dependencies to dedicated groups
@la4de has made a very useful playground for Strawberry, available (for now) here -> https://la4de.github.io/strawberry-playground/

Unfortunately some of the default dependencies aren't uploaded as wheels (see https://github.com/la4de/strawberry-playground/issues/1).

Maybe it could time to move some of these deps to specific groups, we definitely don't need python-multipart installed by default :)

Here's a list of proposed groups based on dependencies installed when doing `pip install strawberry-graphql`:

**Default**:
 
- cached-property
- sentinel
- typing-extensions
- graphql-core
- python-dateutil (I think we need this because of compatibility with python 3.7)

**CLI**:

- click
- pygments

**All web frameworks**:

- python-multipart





Discussion:

Resolving patch:
diff --git a/strawberry/utils/debug.py b/strawberry/utils/debug.py
--- a/strawberry/utils/debug.py
+++ b/strawberry/utils/debug.py
@@ -3,11 +3,6 @@
 from json import JSONEncoder
 from typing import Any, Dict, Optional
 
-from pygments import highlight, lexers
-from pygments.formatters import Terminal256Formatter
-
-from .graphql_lexer import GraphQLLexer
-
 
 class StrawberryJSONEncoder(JSONEncoder):
     def default(self, o: Any) -> Any:
@@ -21,6 +16,17 @@ def pretty_print_graphql_operation(
 
     Won't print introspection operation to prevent noise in the output."""
 
+    try:
+        from pygments import highlight, lexers
+        from pygments.formatters import Terminal256Formatter
+    except ImportError as e:
+        raise ImportError(
+            "pygments is not installed but is required for debug output, install it "
+            "directly or run `pip install strawberry-graphql[debug-server]`"
+        ) from e
+
+    from .graphql_lexer import GraphQLLexer
+
     if operation_name == "IntrospectionQuery":
         return
 


Test patch:
Repository: strawberry-graphql/strawberry

Issue:
Fix enum_value handling for inputs
A clean and easy solution for fixing the broken enum_value handling for inputs

Closes https://github.com/strawberry-graphql/strawberry/issues/2305
Closes https://github.com/strawberry-graphql/strawberry/pull/2203
Closes https://github.com/strawberry-graphql/strawberry/pull/2185
Closes https://github.com/strawberry-graphql/strawberry/pull/2306

@patrick91 sorry for stealing your release file and tests


Discussion:

Resolving patch:
diff --git a/strawberry/enum.py b/strawberry/enum.py
--- a/strawberry/enum.py
+++ b/strawberry/enum.py
@@ -102,6 +102,11 @@ def _process_enum(
             deprecation_reason = item_value.deprecation_reason
             item_value = item_value.value
 
+            # update _value2member_map_ so that doing `MyEnum.MY_VALUE` and
+            # `MyEnum['MY_VALUE']` both work
+            cls._value2member_map_[item_value] = item
+            cls._member_map_[item_name]._value_ = item_value
+
         value = EnumValue(
             item_name,
             item_value,


Test patch:
diff --git a/tests/enums/test_enum.py b/tests/enums/test_enum.py
--- a/tests/enums/test_enum.py
+++ b/tests/enums/test_enum.py
@@ -116,3 +116,19 @@ class IceCreamFlavour(Enum):
     assert definition.values[2].name == "CHOCOLATE"
     assert definition.values[2].value == "chocolate"
     assert definition.values[2].description is None
+
+
+def test_can_use_enum_values():
+    @strawberry.enum
+    class TestEnum(Enum):
+        A = "A"
+        B = strawberry.enum_value("B")
+        C = strawberry.enum_value("Coconut", deprecation_reason="We ran out")
+
+    assert TestEnum.B.value == "B"
+
+    assert [x.value for x in TestEnum.__members__.values()] == [
+        "A",
+        "B",
+        "Coconut",
+    ]
diff --git a/tests/schema/test_enum.py b/tests/schema/test_enum.py
--- a/tests/schema/test_enum.py
+++ b/tests/schema/test_enum.py
@@ -401,3 +401,35 @@ def best_flavour(self) -> IceCreamFlavour:
         {"deprecationReason": "We ran out", "isDeprecated": True, "name": "STRAWBERRY"},
         {"deprecationReason": None, "isDeprecated": False, "name": "CHOCOLATE"},
     ]
+
+
+def test_can_use_enum_values_in_input():
+    @strawberry.enum
+    class TestEnum(Enum):
+        A = "A"
+        B = strawberry.enum_value("B")
+        C = strawberry.enum_value("Coconut", deprecation_reason="We ran out")
+
+    @strawberry.type
+    class Query:
+        @strawberry.field
+        def receive_enum(self, test: TestEnum) -> str:
+            return str(test)
+
+    schema = strawberry.Schema(query=Query)
+
+    query = """
+    query {
+        a: receiveEnum(test: A)
+        b: receiveEnum(test: B)
+        c: receiveEnum(test: C)
+    }
+    """
+
+    result = schema.execute_sync(query)
+
+    assert not result.errors
+    assert result.data
+    assert result.data["a"] == "TestEnum.A"
+    assert result.data["b"] == "TestEnum.B"
+    assert result.data["c"] == "TestEnum.C"
Repository: strawberry-graphql/strawberry

Issue:
ContrainedFloatValue from pydantic needs support
<!-- Provide a general summary of the bug in the title above. -->

<!--- This template is entirely optional and can be removed, but is here to help both you and us. -->
<!--- Anything on lines wrapped in comments like these will not show up in the final text. -->

## Describe the Bug

<!-- A clear and concise description of what the bug is. -->

I am trying to import the below into a strawberry type

```
class coordinates(BaseModel):
    latitude: float= Field(...,gt=-90,lt=90)
    longitude: float= Field(...,gt=-180,lt=180)
    accuracy: int | None = Field(None, gt=50, lt=100)
```

However, I run into this error:

TypeError: Coordinates fields cannot be resolved. Unexpected type '<class 'schema.ConstrainedFloatValue'>'

If, I change `latitude: float= Field(...,gt=-90,lt=90)` into `latitude: int= Field(...,gt=-90,lt=90)`

Then importing using the below works:

```
@strawberry.experimental.pydantic.type(model=coordinates)
class Coordinates:
    """ 
    Class that takes in coordinates from GeoLocation Provider in front-end
    """ 
    latitude: strawberry.auto
    longitude: strawberry.auto
    accuracy: strawberry.auto
    timestamp: Date
```




Discussion:

Resolving patch:
diff --git a/strawberry/experimental/pydantic/fields.py b/strawberry/experimental/pydantic/fields.py
--- a/strawberry/experimental/pydantic/fields.py
+++ b/strawberry/experimental/pydantic/fields.py
@@ -76,6 +76,8 @@
 def get_basic_type(type_) -> Type[Any]:
     if lenient_issubclass(type_, pydantic.ConstrainedInt):
         return int
+    if lenient_issubclass(type_, pydantic.ConstrainedFloat):
+        return float
     if lenient_issubclass(type_, pydantic.ConstrainedStr):
         return str
     if lenient_issubclass(type_, pydantic.ConstrainedList):


Test patch:
diff --git a/tests/experimental/pydantic/test_fields.py b/tests/experimental/pydantic/test_fields.py
--- a/tests/experimental/pydantic/test_fields.py
+++ b/tests/experimental/pydantic/test_fields.py
@@ -88,6 +88,23 @@ class Type:
     assert field.type is int
 
 
+def test_confloat():
+    class Model(pydantic.BaseModel):
+        field: pydantic.confloat(lt=100.5)
+
+    @strawberry.experimental.pydantic.type(Model)
+    class Type:
+        field: strawberry.auto
+
+    definition: TypeDefinition = Type._type_definition
+    assert definition.name == "Type"
+
+    [field] = definition.fields
+
+    assert field.python_name == "field"
+    assert field.type is float
+
+
 def test_constr():
     class Model(pydantic.BaseModel):
         field: pydantic.constr(max_length=100)