Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#3553)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.4.10 → v0.6.3](astral-sh/ruff-pre-commit@v0.4.10...v0.6.3)
- [github.com/adamchainz/blacken-docs: 1.16.0 → 1.18.0](adamchainz/blacken-docs@1.16.0...1.18.0)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Apply fixes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix method

* Snapshots

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Patrick Arminio <patrick.arminio@gmail.com>
  • Loading branch information
pre-commit-ci[bot] and patrick91 authored Sep 4, 2024
1 parent 824e534 commit fc25e04
Show file tree
Hide file tree
Showing 19 changed files with 33 additions and 53 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.10
rev: v0.6.3
hooks:
- id: ruff-format
exclude: ^tests/\w+/snapshots/
Expand Down Expand Up @@ -31,7 +31,7 @@ repos:
args: ["--branch", "main"]

- repo: https://github.com/adamchainz/blacken-docs
rev: 1.16.0
rev: 1.18.0
hooks:
- id: blacken-docs
args: [--skip-errors]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ exclude = [
"dist",
"node_modules",
"venv",
"tests/codegen/snapshots"
"tests/*/snapshots"
]
src = ["strawberry", "tests"]

Expand Down
7 changes: 2 additions & 5 deletions strawberry/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,11 @@ def prime_many(self, data: Mapping[K, T], force: bool = False) -> None:


def should_create_new_batch(loader: DataLoader, batch: Batch) -> bool:
if (
return bool(
batch.dispatched
or loader.max_batch_size
and len(batch) >= loader.max_batch_size
):
return True

return False
)


def get_current_batch(loader: DataLoader) -> Batch:
Expand Down
5 changes: 1 addition & 4 deletions strawberry/types/union.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,7 @@ def is_valid_union_type(type_: object) -> bool:
if isinstance(type_, StrawberryUnion):
return True

if get_origin(type_) is Annotated:
return True

return False
return get_origin(type_) is Annotated


def union(
Expand Down
4 changes: 2 additions & 2 deletions strawberry/utils/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def is_list(annotation: object) -> bool:
"""Returns True if annotation is a List."""
annotation_origin = getattr(annotation, "__origin__", None)

return annotation_origin == list
return annotation_origin is list


def is_union(annotation: object) -> bool:
Expand Down Expand Up @@ -313,7 +313,7 @@ def _get_namespace_from_ast(
# can properly resolve it later
type_name = args[0].strip(" '\"\n")
for arg in args[1:]:
evaled_arg = eval(arg, globalns, localns) # noqa: PGH001, S307
evaled_arg = eval(arg, globalns, localns) # noqa: S307
if isinstance(evaled_arg, StrawberryLazyReference):
extra[type_name] = evaled_arg.resolve_forward_ref(ForwardRef(type_name))

Expand Down
8 changes: 0 additions & 8 deletions tests/experimental/pydantic/schema/test_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ class User: ...
class Query:
a: User = strawberry.field()

@strawberry.field
def a(self) -> User:
return User()

schema = strawberry.Schema(Query)

expected = """
Expand Down Expand Up @@ -95,10 +91,6 @@ class User: ...
class Query:
a: User = strawberry.field()

@strawberry.field
def a(self) -> User:
return User()

schema = strawberry.Schema(Query)

expected = """
Expand Down
2 changes: 1 addition & 1 deletion tests/experimental/pydantic/test_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class User:
assert len(definition.fields) == 1
assert definition.fields[0].python_name == "age"
assert definition.fields[0].graphql_name is None
assert definition.fields[0].type == int
assert definition.fields[0].type is int


def test_can_convert_pydantic_type_with_nested_data_to_strawberry():
Expand Down
2 changes: 1 addition & 1 deletion tests/fields/test_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def name(

assert argument.python_name == "argument"
assert argument.graphql_name is None
assert argument.type == str
assert argument.type is str
assert argument.description == "This is a description"
assert argument.type is str

Expand Down
12 changes: 6 additions & 6 deletions tests/fields/test_resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Query:

assert definition.fields[0].python_name == "name"
assert definition.fields[0].graphql_name is None
assert definition.fields[0].type == str
assert definition.fields[0].type is str
assert definition.fields[0].base_resolver.wrapped_func == get_name


Expand All @@ -53,7 +53,7 @@ def name(self) -> str:

assert definition.fields[0].python_name == "name"
assert definition.fields[0].graphql_name is None
assert definition.fields[0].type == str
assert definition.fields[0].type is str
assert definition.fields[0].base_resolver(None) == Query().name()


Expand All @@ -72,7 +72,7 @@ def name() -> str:

assert definition.fields[0].python_name == "name"
assert definition.fields[0].graphql_name is None
assert definition.fields[0].type == str
assert definition.fields[0].type is str
assert definition.fields[0].base_resolver() == Query.name()

assert Query.name() == "Name"
Expand All @@ -96,7 +96,7 @@ def val(cls) -> str:

assert definition.fields[0].python_name == "val"
assert definition.fields[0].graphql_name is None
assert definition.fields[0].type == str
assert definition.fields[0].type is str
assert definition.fields[0].base_resolver() == Query.val()

assert Query.val() == "thingy"
Expand Down Expand Up @@ -310,13 +310,13 @@ class Query:
assert definition.fields[0].python_name == "name"
assert definition.fields[0].graphql_name is None
assert definition.fields[0].python_name == "name"
assert definition.fields[0].type == str
assert definition.fields[0].type is str
assert definition.fields[0].base_resolver.wrapped_func == get_name

assert definition.fields[1].python_name == "name_2"
assert definition.fields[1].graphql_name is None
assert definition.fields[1].python_name == "name_2"
assert definition.fields[1].type == str
assert definition.fields[1].type is str
assert definition.fields[1].base_resolver.wrapped_func == get_name


Expand Down
3 changes: 1 addition & 2 deletions tests/http/clients/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,8 @@ async def __aiter__(self) -> AsyncGenerator[Message, None]:


class DebuggableGraphQLTransportWSMixin:
@staticmethod
def on_init(self) -> None:
"""This method can be patched by unittests to get the instance of the
"""This method can be patched by unit tests to get the instance of the
transport handler when it is initialized.
"""

Expand Down
6 changes: 3 additions & 3 deletions tests/objects/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class User(Node):

assert definition.fields[1].python_name == "name"
assert definition.fields[1].graphql_name is None
assert definition.fields[1].type == str
assert definition.fields[1].type is str

assert definition.is_interface is False
assert definition.interfaces == [Node.__strawberry_definition__]
Expand Down Expand Up @@ -68,7 +68,7 @@ class Person(Node):

assert definition.fields[1].python_name == "name"
assert definition.fields[1].graphql_name is None
assert definition.fields[1].type == str
assert definition.fields[1].type is str

assert definition.is_interface is False
assert definition.interfaces == [Node.__strawberry_definition__]
Expand All @@ -84,7 +84,7 @@ class Person(Node):

assert definition.fields[1].python_name == "name"
assert definition.fields[1].graphql_name is None
assert definition.fields[1].type == str
assert definition.fields[1].type is str

assert definition.is_interface is False
assert definition.interfaces == [Node.__strawberry_definition__]
Expand Down
4 changes: 1 addition & 3 deletions tests/schema/extensions/test_mask_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ def hidden_error(self) -> str:

def should_mask_error(error: GraphQLError) -> bool:
original_error = error.original_error
if original_error and isinstance(original_error, VisibleError):
return False
return True
return not (original_error and isinstance(original_error, VisibleError))

schema = strawberry.Schema(
query=Query, extensions=[MaskErrors(should_mask_error=should_mask_error)]
Expand Down
2 changes: 1 addition & 1 deletion tests/schema/test_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def field(self, info: strawberry.Info) -> return_type:

def test_return_type_from_field():
def resolver(info):
assert info.return_type == int
assert info.return_type is int
return 0

@strawberry.type
Expand Down
5 changes: 1 addition & 4 deletions tests/schema/test_permission.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,10 +568,7 @@ class IsAuthorized(BasePermission):
def has_permission(
self, source, info, **kwargs: typing.Any
) -> bool: # pragma: no cover
if kwargs["a_key"] == "secret":
return True

return False
return kwargs["a_key"] == "secret"

@strawberry.type
class Query:
Expand Down
2 changes: 1 addition & 1 deletion tests/schema/test_private_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Query:

assert definition.fields[0].python_name == "name"
assert definition.fields[0].graphql_name is None
assert definition.fields[0].type == str
assert definition.fields[0].type is str

instance = Query(name="Luke", age=22)
assert instance.name == "Luke"
Expand Down
10 changes: 5 additions & 5 deletions tests/tools/test_create_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def name() -> str:

assert definition.fields[0].python_name == "name"
assert definition.fields[0].graphql_name is None
assert definition.fields[0].type == str
assert definition.fields[0].type is str


def test_create_type_extend_and_directives():
Expand All @@ -52,7 +52,7 @@ def name() -> str:

assert definition.fields[0].python_name == "name"
assert definition.fields[0].graphql_name is None
assert definition.fields[0].type == str
assert definition.fields[0].type is str


def test_create_input_type():
Expand All @@ -73,7 +73,7 @@ def test_create_input_type():

assert definition.fields[0].python_name == "name"
assert definition.fields[0].graphql_name is None
assert definition.fields[0].type == str
assert definition.fields[0].type is str


def test_create_interface_type():
Expand All @@ -95,7 +95,7 @@ def test_create_interface_type():

assert definition.fields[0].python_name == "name"
assert definition.fields[0].graphql_name is None
assert definition.fields[0].type == str
assert definition.fields[0].type is str


def test_create_variable_type():
Expand All @@ -111,7 +111,7 @@ def get_name() -> str:

assert definition.fields[0].python_name == "get_name"
assert definition.fields[0].graphql_name == "name"
assert definition.fields[0].type == str
assert definition.fields[0].type is str


def test_create_type_empty_list():
Expand Down
4 changes: 2 additions & 2 deletions tests/types/test_annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ def __eq__(self, other):


def test_eq_on_non_annotation():
assert StrawberryAnnotation(int) != int
assert StrawberryAnnotation(int) is not int
assert StrawberryAnnotation(int) != 123


def test_set_anntation():
annotation = StrawberryAnnotation(int)
annotation.annotation = str

assert annotation.annotation == str
assert annotation.annotation is str
2 changes: 1 addition & 1 deletion tests/types/test_argument_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def get_name(id_: int) -> str:
return "Lord Buckethead"

argument = get_name.arguments[0]
assert argument.type == int
assert argument.type is int


def test_object():
Expand Down
2 changes: 1 addition & 1 deletion tests/types/test_object_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Fabric:

field: StrawberryField = get_object_definition(Fabric).fields[0]

assert field.type == str
assert field.type is str


def test_object():
Expand Down

0 comments on commit fc25e04

Please sign in to comment.