Skip to content

Commit

Permalink
Merge branch 'main' into fastapi-kwargs
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick91 committed Apr 14, 2024
2 parents b40c67a + 04e5d4e commit 52f609c
Show file tree
Hide file tree
Showing 95 changed files with 277 additions and 166 deletions.
49 changes: 48 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ pytest-mypy-plugins = ">=1.10,<4.0"
poetry-plugin-export = "^1.6.0"
# another bug in poetry
urllib3 = "<2"
ruff = "^0.3.7"

[tool.poetry.group.integrations]
optional = true
Expand Down Expand Up @@ -239,8 +240,6 @@ ignore = [
# definitely enable these, maybe not in tests
"ANN102",
"ANN202",
"ANN204",
"ANN205",
"ANN401",
"PGH003",
"PGH004",
Expand Down Expand Up @@ -355,7 +354,22 @@ ignore = [

[tool.ruff.lint.per-file-ignores]
"strawberry/schema/types/concrete_type.py" = ["TCH002"]
"tests/*" = ["RSE102", "SLF001", "TCH001", "TCH002", "TCH003", "ANN001", "ANN201", "PLW0603", "PLC1901", "S603", "S607", "B018"]
"tests/*" = [
"RSE102",
"SLF001",
"TCH001",
"TCH002",
"TCH003",
"ANN001",
"ANN201",
"ANN202",
"ANN204",
"PLW0603",
"PLC1901",
"S603",
"S607",
"B018",
]
"strawberry/extensions/tracing/__init__.py" = ["TCH004"]
"tests/http/clients/__init__.py" = ["F401"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(
get_context: Callable[..., Dict[str, Any]],
get_root_value: Any,
request: web.Request,
):
) -> None:
super().__init__(schema, debug, connection_init_wait_timeout)
self._get_context = get_context
self._get_root_value = get_root_value
Expand Down
2 changes: 1 addition & 1 deletion strawberry/aiohttp/handlers/graphql_ws_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(
get_context: Callable,
get_root_value: Callable,
request: web.Request,
):
) -> None:
super().__init__(schema, debug, keep_alive, keep_alive_interval)
self._get_context = get_context
self._get_root_value = get_root_value
Expand Down
4 changes: 2 additions & 2 deletions strawberry/aiohttp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@


class AioHTTPRequestAdapter(AsyncHTTPRequestAdapter):
def __init__(self, request: web.Request):
def __init__(self, request: web.Request) -> None:
self.request = request

@property
Expand Down Expand Up @@ -100,7 +100,7 @@ def __init__(
GRAPHQL_WS_PROTOCOL,
),
connection_init_wait_timeout: timedelta = timedelta(minutes=1),
):
) -> None:
self.schema = schema
self.allow_queries_via_get = allow_queries_via_get
self.keep_alive = keep_alive
Expand Down
2 changes: 1 addition & 1 deletion strawberry/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(
annotation: Union[object, str],
*,
namespace: Optional[Dict[str, Any]] = None,
):
) -> None:
self.raw_annotation = annotation
self.namespace = namespace

Expand Down
2 changes: 1 addition & 1 deletion strawberry/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(
deprecation_reason: Optional[str] = None,
directives: Iterable[object] = (),
metadata: Optional[Mapping[Any, Any]] = None,
):
) -> None:
self.description = description
self.name = name
self.deprecation_reason = deprecation_reason
Expand Down
2 changes: 1 addition & 1 deletion strawberry/asgi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def __init__(
else:
self.graphql_ide = graphql_ide

async def __call__(self, scope: Scope, receive: Receive, send: Send):
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
if scope["type"] == "http":
return await self.handle_http(scope, receive, send)

Expand Down
2 changes: 1 addition & 1 deletion strawberry/asgi/handlers/graphql_transport_ws_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(
get_context: Callable,
get_root_value: Callable,
ws: WebSocket,
):
) -> None:
super().__init__(schema, debug, connection_init_wait_timeout)
self._get_context = get_context
self._get_root_value = get_root_value
Expand Down
2 changes: 1 addition & 1 deletion strawberry/asgi/handlers/graphql_ws_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(
get_context: Callable,
get_root_value: Callable,
ws: WebSocket,
):
) -> None:
super().__init__(schema, debug, keep_alive, keep_alive_interval)
self._get_context = get_context
self._get_root_value = get_root_value
Expand Down
2 changes: 1 addition & 1 deletion strawberry/asgi/test/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ def request(
headers=headers,
)

def _decode(self, response: Any, type: Literal["multipart", "json"]):
def _decode(self, response: Any, type: Literal["multipart", "json"]) -> Any:
return response.json()
10 changes: 5 additions & 5 deletions strawberry/auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class StrawberryAutoMeta(type):
"""

def __init__(self, *args: str, **kwargs: Any):
def __init__(self, *args: str, **kwargs: Any) -> None:
self._instance: Optional[StrawberryAuto] = None
super().__init__(*args, **kwargs)

def __call__(cls, *args: str, **kwargs: Any):
def __call__(cls, *args: str, **kwargs: Any) -> Any:
if cls._instance is None:
cls._instance = super().__call__(*args, **kwargs)

Expand All @@ -37,7 +37,7 @@ def __call__(cls, *args: str, **kwargs: Any):
def __instancecheck__(
self,
instance: Union[StrawberryAuto, StrawberryAnnotation, StrawberryType, type],
):
) -> bool:
if isinstance(instance, StrawberryAnnotation):
resolved = instance.raw_annotation
if isinstance(resolved, str):
Expand Down Expand Up @@ -69,10 +69,10 @@ def __instancecheck__(


class StrawberryAuto(metaclass=StrawberryAutoMeta):
def __str__(self):
def __str__(self) -> str:
return "auto"

def __repr__(self):
def __repr__(self) -> str:
return "<auto>"


Expand Down
4 changes: 2 additions & 2 deletions strawberry/chalice/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


class ChaliceHTTPRequestAdapter(SyncHTTPRequestAdapter):
def __init__(self, request: Request):
def __init__(self, request: Request) -> None:
self.request = request

@property
Expand Down Expand Up @@ -62,7 +62,7 @@ def __init__(
graphiql: Optional[bool] = None,
graphql_ide: Optional[GraphQL_IDE] = "graphiql",
allow_queries_via_get: bool = True,
):
) -> None:
self.allow_queries_via_get = allow_queries_via_get
self.schema = schema
if graphiql is not None:
Expand Down
2 changes: 1 addition & 1 deletion strawberry/channels/handlers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class ChannelsConsumer(AsyncConsumer):
channel_layer: Optional[ChannelsLayer]
channel_receive: Callable[[], Awaitable[dict]]

def __init__(self, *args: str, **kwargs: Any):
def __init__(self, *args: str, **kwargs: Any) -> None:
self.listen_queues: DefaultDict[str, WeakSet[asyncio.Queue]] = defaultdict(
WeakSet
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(
get_context: Callable,
get_root_value: Callable,
ws: ChannelsWSConsumer,
):
) -> None:
super().__init__(schema, debug, connection_init_wait_timeout)
self._get_context = get_context
self._get_root_value = get_root_value
Expand Down
2 changes: 1 addition & 1 deletion strawberry/channels/handlers/graphql_ws_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(
get_context: Callable,
get_root_value: Callable,
ws: ChannelsWSConsumer,
):
) -> None:
super().__init__(schema, debug, keep_alive, keep_alive_interval)
self._get_context = get_context
self._get_root_value = get_root_value
Expand Down
4 changes: 2 additions & 2 deletions strawberry/channels/handlers/http_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def form_data(self) -> FormData:


class BaseChannelsRequestAdapter:
def __init__(self, request: ChannelsRequest):
def __init__(self, request: ChannelsRequest) -> None:
self.request = request

@property
Expand Down Expand Up @@ -156,7 +156,7 @@ def __init__(
allow_queries_via_get: bool = True,
subscriptions_enabled: bool = True,
**kwargs: Any,
):
) -> None:
self.schema = schema
self.allow_queries_via_get = allow_queries_via_get
self.subscriptions_enabled = subscriptions_enabled
Expand Down
2 changes: 1 addition & 1 deletion strawberry/channels/handlers/ws_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(
GRAPHQL_WS_PROTOCOL,
),
connection_init_wait_timeout: Optional[datetime.timedelta] = None,
):
) -> None:
if connection_init_wait_timeout is None:
connection_init_wait_timeout = datetime.timedelta(minutes=1)
self.connection_init_wait_timeout = connection_init_wait_timeout
Expand Down
2 changes: 1 addition & 1 deletion strawberry/channels/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(
schema: BaseSchema,
django_application: Optional[str] = None,
url_pattern: str = "^graphql",
):
) -> None:
http_urls = [re_path(url_pattern, GraphQLHTTPConsumer.as_asgi(schema=schema))]
if django_application is not None:
http_urls.append(re_path("^", django_application))
Expand Down
2 changes: 1 addition & 1 deletion strawberry/channels/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(
protocol: str = GRAPHQL_TRANSPORT_WS_PROTOCOL,
connection_params: dict = {},
**kwargs: Any,
):
) -> None:
"""
Args:
Expand Down

0 comments on commit 52f609c

Please sign in to comment.