Skip to content

Commit

Permalink
Update Ruff (#2395)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick91 committed Dec 12, 2022
1 parent 30e1d2a commit db81482
Show file tree
Hide file tree
Showing 115 changed files with 4 additions and 138 deletions.
1 change: 0 additions & 1 deletion .github/bot-action/main.py
Expand Up @@ -4,7 +4,6 @@

import httpx


API_URL = os.environ["BOT_API_URL"]
API_TOKEN = os.environ["API_SECRET"]

Expand Down
1 change: 0 additions & 1 deletion .github/release-check-action/check.py
Expand Up @@ -4,7 +4,6 @@
from config import GITHUB_WORKSPACE, RELEASE_FILE_PATH
from release import InvalidReleaseFileError, get_release_info


release_file = pathlib.Path(GITHUB_WORKSPACE) / RELEASE_FILE_PATH

release_info = None
Expand Down
1 change: 0 additions & 1 deletion .github/release-check-action/config.py
@@ -1,6 +1,5 @@
import os


RELEASE_FILE_PATH = "RELEASE.md"
GITHUB_SHA = os.environ["GITHUB_SHA"]
GITHUB_EVENT_PATH = os.environ["GITHUB_EVENT_PATH"]
Expand Down
1 change: 0 additions & 1 deletion .github/release-check-action/release.py
Expand Up @@ -3,7 +3,6 @@
from enum import Enum
from pathlib import Path


RELEASE_TYPE_REGEX = re.compile(r"^[Rr]elease [Tt]ype: (major|minor|patch)$")


Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
@@ -1,12 +1,12 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.0
rev: v3.3.1
hooks:
- id: pyupgrade
args: [--py37-plus, --keep-runtime-typing]

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.158
rev: v0.0.176
hooks:
- id: ruff
exclude: ^tests/codegen/snapshots/python/
Expand All @@ -32,7 +32,7 @@ repos:
- id: check-toml

- repo: https://github.com/psf/black
rev: 22.10.0
rev: 22.12.0
hooks:
- id: black
exclude: ^tests/codegen/snapshots/python/
14 changes: 1 addition & 13 deletions pyproject.toml
Expand Up @@ -158,7 +158,7 @@ stubPath = ""
[tool.ruff]
line-length = 88
select = ["E", "F", "ERA", "I"]
ignore = ["I252"]
ignore = ["TID252"]
fix = true
exclude = [
".bzr",
Expand Down Expand Up @@ -189,18 +189,6 @@ src = ["strawberry", "tests"]
"tests/test_printer/test_basic.py" = ["E501"]
"tests/pyright/test_federation.py" = ["E501"]
"tests/test_printer/test_schema_directives.py" = ["E501"]
# temporary until https://github.com/charliermarsh/ruff/issues/960 is fixed
"tests/federation/printer/test_entities.py" = ["F821"]
"tests/federation/printer/test_keys.py" = ["F821"]
"tests/federation/printer/test_provides.py" = ["F821"]
"tests/schema/test_resolvers.py" = ["F821"]
"tests/test_forward_references.py" = ["F821"]
"tests/types/resolving/test_string_annotations.py" = ["F821"]
"tests/types/test_argument_types.py" = ["F821"]
"tests/types/test_object_types.py" = ["F821"]
"tests/types/test_resolver_types.py" = ["F821"]
"tests/federation/printer/test_requires.py" = ["F821"]
"tests/schema/test_private_field.py" = ["F821"]

[tool.ruff.isort]
known-first-party = ["strawberry"]
Expand Down
1 change: 0 additions & 1 deletion setup.py
Expand Up @@ -5,6 +5,5 @@

import setuptools


if __name__ == "__main__":
setuptools.setup(name="strawberry-graphql")
1 change: 0 additions & 1 deletion strawberry/__init__.py
Expand Up @@ -16,7 +16,6 @@
from .union import union
from .unset import UNSET


__all__ = [
"BasePermission",
"experimental",
Expand Down
1 change: 0 additions & 1 deletion strawberry/__main__.py
@@ -1,5 +1,4 @@
from .cli import run


if __name__ == "__main__":
run()
1 change: 0 additions & 1 deletion strawberry/aiohttp/handlers/__init__.py
Expand Up @@ -4,5 +4,4 @@
from strawberry.aiohttp.handlers.graphql_ws_handler import GraphQLWSHandler
from strawberry.aiohttp.handlers.http_handler import HTTPHandler


__all__ = ["GraphQLTransportWSHandler", "GraphQLWSHandler", "HTTPHandler"]
1 change: 0 additions & 1 deletion strawberry/aiohttp/test/__init__.py
@@ -1,4 +1,3 @@
from .client import GraphQLTestClient


__all__ = ["GraphQLTestClient"]
3 changes: 0 additions & 3 deletions strawberry/annotation.py
Expand Up @@ -17,7 +17,6 @@
from strawberry.exceptions.not_a_strawberry_enum import NotAStrawberryEnumError
from strawberry.private import is_private


try:
from typing import ForwardRef
except ImportError: # pragma: no cover
Expand All @@ -37,7 +36,6 @@
from strawberry.unset import UNSET
from strawberry.utils.typing import is_generic, is_list, is_type_var, is_union


if TYPE_CHECKING:
from strawberry.field import StrawberryField
from strawberry.union import StrawberryUnion
Expand Down Expand Up @@ -347,5 +345,4 @@ def _is_input_type(type_: Any) -> bool:


def _is_object_type(type_: Any) -> bool:
# isinstance(type_, StrawberryObjectType) # noqa: E800
return hasattr(type_, "_type_definition")
1 change: 0 additions & 1 deletion strawberry/arguments.py
Expand Up @@ -27,7 +27,6 @@
from .unset import UNSET as _deprecated_UNSET
from .unset import _deprecated_is_unset # noqa


if TYPE_CHECKING:
from strawberry.schema.config import StrawberryConfig

Expand Down
1 change: 0 additions & 1 deletion strawberry/asgi/handlers/__init__.py
Expand Up @@ -4,5 +4,4 @@
from strawberry.asgi.handlers.graphql_ws_handler import GraphQLWSHandler
from strawberry.asgi.handlers.http_handler import HTTPHandler


__all__ = ["GraphQLTransportWSHandler", "GraphQLWSHandler", "HTTPHandler"]
1 change: 0 additions & 1 deletion strawberry/asgi/test/__init__.py
@@ -1,4 +1,3 @@
from .client import GraphQLTestClient


__all__ = ["GraphQLTestClient"]
1 change: 0 additions & 1 deletion strawberry/channels/__init__.py
Expand Up @@ -5,7 +5,6 @@
from .handlers.ws_handler import GraphQLWSConsumer
from .router import GraphQLProtocolTypeRouter


__all__ = [
"GraphQLProtocolTypeRouter",
"GraphQLWSHandler",
Expand Down
1 change: 0 additions & 1 deletion strawberry/channels/context.py
@@ -1,7 +1,6 @@
from dataclasses import dataclass
from typing import TYPE_CHECKING


if TYPE_CHECKING:
from strawberry.channels.handlers.base import ChannelsConsumer

Expand Down
1 change: 0 additions & 1 deletion strawberry/cli/debug_server.py
Expand Up @@ -11,7 +11,6 @@
)
from strawberry.utils.importer import import_module_symbol


app = Starlette(debug=True)
app.add_middleware(
CORSMiddleware, allow_headers=["*"], allow_origins=["*"], allow_methods=["*"]
Expand Down
1 change: 0 additions & 1 deletion strawberry/codegen/__init__.py
@@ -1,4 +1,3 @@
from .query_codegen import CodegenFile, CodegenResult, QueryCodegen, QueryCodegenPlugin


__all__ = ["QueryCodegen", "QueryCodegenPlugin", "CodegenFile", "CodegenResult"]
1 change: 0 additions & 1 deletion strawberry/custom_scalar.py
Expand Up @@ -20,7 +20,6 @@

from .utils.str_converters import to_camel_case


# in python 3.10+ NewType is a class
if sys.version_info >= (3, 10):
_T = TypeVar("_T", bound=Union[type, NewType])
Expand Down
1 change: 0 additions & 1 deletion strawberry/dataloader.py
Expand Up @@ -21,7 +21,6 @@

from .exceptions import WrongNumberOfResultsReturned


T = TypeVar("T")
K = TypeVar("K")

Expand Down
1 change: 0 additions & 1 deletion strawberry/django/test/__init__.py
@@ -1,4 +1,3 @@
from .client import GraphQLTestClient


__all__ = ["GraphQLTestClient"]
1 change: 0 additions & 1 deletion strawberry/exceptions/__init__.py
Expand Up @@ -23,7 +23,6 @@
from .scalar_already_registered import ScalarAlreadyRegisteredError
from .unresolved_field_type import UnresolvedFieldTypeError


setup_exception_handler()


Expand Down
1 change: 0 additions & 1 deletion strawberry/exceptions/exception.py
Expand Up @@ -6,7 +6,6 @@

from .exception_source import ExceptionSource


if TYPE_CHECKING:
from rich.console import RenderableType

Expand Down
1 change: 0 additions & 1 deletion strawberry/exceptions/handler.py
Expand Up @@ -6,7 +6,6 @@

from .exception import StrawberryException, UnableToFindExceptionSource


original_exception_hook = sys.excepthook


Expand Down
1 change: 0 additions & 1 deletion strawberry/exceptions/invalid_argument_type.py
Expand Up @@ -8,7 +8,6 @@
from .exception_source import ExceptionSource
from .utils.source_finder import SourceFinder


if TYPE_CHECKING:
from strawberry.arguments import StrawberryArgument
from strawberry.types.fields.resolver import StrawberryResolver
Expand Down
1 change: 0 additions & 1 deletion strawberry/exceptions/invalid_union_type.py
Expand Up @@ -10,7 +10,6 @@
from .exception import StrawberryException
from .exception_source import ExceptionSource


if TYPE_CHECKING:
from strawberry.union import StrawberryUnion

Expand Down
1 change: 0 additions & 1 deletion strawberry/exceptions/scalar_already_registered.py
Expand Up @@ -9,7 +9,6 @@
from .exception import StrawberryException
from .exception_source import ExceptionSource


if TYPE_CHECKING:
from strawberry.custom_scalar import ScalarDefinition

Expand Down
1 change: 0 additions & 1 deletion strawberry/exceptions/utils/source_finder.py
Expand Up @@ -12,7 +12,6 @@

from ..exception_source import ExceptionSource


if TYPE_CHECKING:
from libcst import CSTNode, FunctionDef

Expand Down
1 change: 0 additions & 1 deletion strawberry/experimental/pydantic/__init__.py
Expand Up @@ -2,7 +2,6 @@
from .exceptions import UnregisteredTypeException
from .object_type import input, interface, type


__all__ = [
"error_type",
"UnregisteredTypeException",
Expand Down
1 change: 0 additions & 1 deletion strawberry/experimental/pydantic/conversion_types.py
Expand Up @@ -7,7 +7,6 @@

from strawberry.types.types import TypeDefinition


PydanticModel = TypeVar("PydanticModel", bound=BaseModel)


Expand Down
1 change: 0 additions & 1 deletion strawberry/experimental/pydantic/fields.py
Expand Up @@ -14,7 +14,6 @@
)
from strawberry.types.types import TypeDefinition


try:
from typing import GenericAlias as TypingGenericAlias # type: ignore
except ImportError:
Expand Down
1 change: 0 additions & 1 deletion strawberry/ext/mypy_plugin.py
Expand Up @@ -60,7 +60,6 @@
from mypy.typevars import fill_typevars
from mypy.util import get_unique_redefinition_name


# Backwards compatible with the removal of `TypeVarDef` in mypy 0.920.
try:
from mypy.types import TypeVarDef # type: ignore
Expand Down
1 change: 0 additions & 1 deletion strawberry/extensions/__init__.py
Expand Up @@ -6,7 +6,6 @@
from .query_depth_limiter import QueryDepthLimiter
from .validation_cache import ValidationCache


__all__ = [
"Extension",
"AddValidationRules",
Expand Down
1 change: 0 additions & 1 deletion strawberry/extensions/directives.py
Expand Up @@ -8,7 +8,6 @@
from strawberry.types import Info
from strawberry.utils.await_maybe import AwaitableOrValue, await_maybe


if TYPE_CHECKING:
from strawberry.schema.schema import Schema

Expand Down
1 change: 0 additions & 1 deletion strawberry/extensions/query_depth_limiter.py
Expand Up @@ -43,7 +43,6 @@
from strawberry.extensions import AddValidationRules
from strawberry.extensions.utils import is_introspection_key


IgnoreType = Union[Callable[[str], bool], re.Pattern, str]


Expand Down
1 change: 0 additions & 1 deletion strawberry/extensions/tracing/__init__.py
@@ -1,7 +1,6 @@
import importlib
from typing import TYPE_CHECKING


if TYPE_CHECKING:
from .apollo import ApolloTracingExtension, ApolloTracingExtensionSync # noqa
from .datadog import DatadogTracingExtension, DatadogTracingExtensionSync # noqa
Expand Down
1 change: 0 additions & 1 deletion strawberry/extensions/tracing/apollo.py
Expand Up @@ -10,7 +10,6 @@

from .utils import should_skip_tracing


DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ"


Expand Down
1 change: 0 additions & 1 deletion strawberry/extensions/tracing/opentelemetry.py
Expand Up @@ -13,7 +13,6 @@

from .utils import should_skip_tracing


DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ"

ArgFilter = Callable[[Dict[str, Any], GraphQLResolveInfo], Dict[str, Any]]
Expand Down
1 change: 0 additions & 1 deletion strawberry/fastapi/__init__.py
@@ -1,4 +1,3 @@
from strawberry.fastapi.router import BaseContext, GraphQLRouter


__all__ = ["BaseContext", "GraphQLRouter"]
1 change: 0 additions & 1 deletion strawberry/fastapi/handlers/__init__.py
Expand Up @@ -3,5 +3,4 @@
)
from strawberry.fastapi.handlers.graphql_ws_handler import GraphQLWSHandler


__all__ = ["GraphQLTransportWSHandler", "GraphQLWSHandler"]
3 changes: 0 additions & 3 deletions strawberry/fastapi/router.py
Expand Up @@ -38,7 +38,6 @@
from strawberry.utils.debug import pretty_print_graphql_operation
from strawberry.utils.graphiql import get_graphiql_html


CustomContext = Union["BaseContext", Dict[str, Any]]
MergedContext = Union[
"BaseContext", Dict[str, Union[Any, BackgroundTasks, Request, Response, WebSocket]]
Expand Down Expand Up @@ -163,8 +162,6 @@ async def handle_http_get(
context=Depends(self.context_getter),
root_value=Depends(self.root_value_getter),
) -> Response:
actual_response: Response

if request.query_params:
try:
query_data = parse_query_params(request.query_params._dict)
Expand Down
1 change: 0 additions & 1 deletion strawberry/federation/__init__.py
Expand Up @@ -7,7 +7,6 @@
from .schema import Schema
from .union import union


__all__ = [
"argument",
"enum",
Expand Down
1 change: 0 additions & 1 deletion strawberry/federation/field.py
Expand Up @@ -18,7 +18,6 @@
from strawberry.permission import BasePermission
from strawberry.unset import UNSET


T = TypeVar("T")


Expand Down
1 change: 0 additions & 1 deletion strawberry/federation/mutation.py
@@ -1,4 +1,3 @@
from .field import field


mutation = field
1 change: 0 additions & 1 deletion strawberry/federation/object_type.py
Expand Up @@ -18,7 +18,6 @@

from .field import field


if TYPE_CHECKING:
from .schema_directives import Key

Expand Down

0 comments on commit db81482

Please sign in to comment.