Skip to content

Commit

Permalink
Update pre-commit (#3464)
Browse files Browse the repository at this point in the history
* Update ruff in precommit

* Lint
  • Loading branch information
patrick91 authored Apr 20, 2024
1 parent 29b7dd8 commit 3edf95d
Show file tree
Hide file tree
Showing 63 changed files with 228 additions and 439 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.2.1
rev: v0.4.1
hooks:
- id: ruff-format
exclude: ^tests/\w+/snapshots/
Expand All @@ -20,7 +20,7 @@ repos:
files: '^docs/.*\.mdx?$'

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: check-merge-conflict
Expand Down
3 changes: 1 addition & 2 deletions federation-compatibility/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ def get_product_by_sku_and_variation(sku: str, variation: dict) -> Optional["Pro
compose=True,
import_url="https://myspecs.dev/myCustomDirective/v1.0",
)
class Custom:
...
class Custom: ...


@strawberry.federation.type(extend=True, keys=["email"])
Expand Down
21 changes: 7 additions & 14 deletions strawberry/channels/handlers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,25 @@ class ChannelsLayer(Protocol): # pragma: no cover

extensions: List[Literal["groups", "flush"]]

async def send(self, channel: str, message: dict) -> None:
...
async def send(self, channel: str, message: dict) -> None: ...

async def receive(self, channel: str) -> dict:
...
async def receive(self, channel: str) -> dict: ...

async def new_channel(self, prefix: str = ...) -> str:
...
async def new_channel(self, prefix: str = ...) -> str: ...

# If groups extension is supported

group_expiry: int

async def group_add(self, group: str, channel: str) -> None:
...
async def group_add(self, group: str, channel: str) -> None: ...

async def group_discard(self, group: str, channel: str) -> None:
...
async def group_discard(self, group: str, channel: str) -> None: ...

async def group_send(self, group: str, message: dict) -> None:
...
async def group_send(self, group: str, message: dict) -> None: ...

# If flush extension is supported

async def flush(self) -> None:
...
async def flush(self) -> None: ...


class ChannelsConsumer(AsyncConsumer):
Expand Down
6 changes: 2 additions & 4 deletions strawberry/codegen/query_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,9 @@ def __init__(self, query: Path) -> None:
"""
self.query = query

def on_start(self) -> None:
...
def on_start(self) -> None: ...

def on_end(self, result: CodegenResult) -> None:
...
def on_end(self, result: CodegenResult) -> None: ...

def generate_code(
self, types: List[GraphQLType], operation: GraphQLOperation
Expand Down
6 changes: 2 additions & 4 deletions strawberry/custom_scalar.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ def scalar(
parse_value: Optional[Callable] = None,
parse_literal: Optional[Callable] = None,
directives: Iterable[object] = (),
) -> Callable[[_T], _T]:
...
) -> Callable[[_T], _T]: ...


@overload
Expand All @@ -149,8 +148,7 @@ def scalar(
parse_value: Optional[Callable] = None,
parse_literal: Optional[Callable] = None,
directives: Iterable[object] = (),
) -> _T:
...
) -> _T: ...


# TODO: We are tricking pyright into thinking that we are returning the given type
Expand Down
6 changes: 2 additions & 4 deletions strawberry/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ def __init__(
loop: Optional[AbstractEventLoop] = None,
cache_map: Optional[AbstractCache[K, T]] = None,
cache_key_fn: Optional[Callable[[K], Hashable]] = None,
) -> None:
...
) -> None: ...

# fallback if load_fn is untyped and there's no other info for inference
@overload
Expand All @@ -118,8 +117,7 @@ def __init__(
loop: Optional[AbstractEventLoop] = None,
cache_map: Optional[AbstractCache[K, T]] = None,
cache_key_fn: Optional[Callable[[K], Hashable]] = None,
) -> None:
...
) -> None: ...

def __init__(
self,
Expand Down
3 changes: 1 addition & 2 deletions strawberry/directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ def directive_field(name: str, default: object = UNSET) -> Any:
T = TypeVar("T")


class StrawberryDirectiveValue:
...
class StrawberryDirectiveValue: ...


DirectiveValue = Annotated[T, StrawberryDirectiveValue()]
Expand Down
2 changes: 1 addition & 1 deletion strawberry/django/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __repr__(self) -> str:
if self.status_code is not None:
return super().__repr__()

return "<{cls} status_code={status_code}{content_type}>".format(
return "<{cls} status_code={status_code}{content_type}>".format( # noqa: UP032
cls=self.__class__.__name__,
status_code=self.status_code,
content_type=self._content_type_for_repr, # pyright: ignore
Expand Down
6 changes: 2 additions & 4 deletions strawberry/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ def enum(
name: Optional[str] = None,
description: Optional[str] = None,
directives: Iterable[object] = (),
) -> EnumType:
...
) -> EnumType: ...


@overload
Expand All @@ -147,8 +146,7 @@ def enum(
name: Optional[str] = None,
description: Optional[str] = None,
directives: Iterable[object] = (),
) -> Callable[[EnumType], EnumType]:
...
) -> Callable[[EnumType], EnumType]: ...


def enum(
Expand Down
15 changes: 5 additions & 10 deletions strawberry/experimental/pydantic/conversion_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,17 @@ class StrawberryTypeFromPydantic(Protocol[PydanticModel]):
"""This class does not exist in runtime.
It only makes the methods below visible for IDEs"""

def __init__(self, **kwargs: Any) -> None:
...
def __init__(self, **kwargs: Any) -> None: ...

@staticmethod
def from_pydantic(
instance: PydanticModel, extra: Optional[Dict[str, Any]] = None
) -> StrawberryTypeFromPydantic[PydanticModel]:
...
) -> StrawberryTypeFromPydantic[PydanticModel]: ...

def to_pydantic(self, **kwargs: Any) -> PydanticModel:
...
def to_pydantic(self, **kwargs: Any) -> PydanticModel: ...

@property
def __strawberry_definition__(self) -> StrawberryObjectDefinition:
...
def __strawberry_definition__(self) -> StrawberryObjectDefinition: ...

@property
def _pydantic_type(self) -> Type[PydanticModel]:
...
def _pydantic_type(self) -> Type[PydanticModel]: ...
6 changes: 2 additions & 4 deletions strawberry/federation/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ def enum(
policy: Optional[List[List[str]]] = None,
requires_scopes: Optional[List[List[str]]] = None,
tags: Optional[Iterable[str]] = (),
) -> EnumType:
...
) -> EnumType: ...


@overload
Expand All @@ -66,8 +65,7 @@ def enum(
policy: Optional[List[List[str]]] = None,
requires_scopes: Optional[List[List[str]]] = None,
tags: Optional[Iterable[str]] = (),
) -> Callable[[EnumType], EnumType]:
...
) -> Callable[[EnumType], EnumType]: ...


def enum(
Expand Down
9 changes: 3 additions & 6 deletions strawberry/federation/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ def field(
directives: Sequence[object] = (),
extensions: Optional[List[FieldExtension]] = None,
graphql_type: Optional[Any] = None,
) -> T:
...
) -> T: ...


@overload
Expand All @@ -83,8 +82,7 @@ def field(
directives: Sequence[object] = (),
extensions: Optional[List[FieldExtension]] = None,
graphql_type: Optional[Any] = None,
) -> Any:
...
) -> Any: ...


@overload
Expand All @@ -111,8 +109,7 @@ def field(
directives: Sequence[object] = (),
extensions: Optional[List[FieldExtension]] = None,
graphql_type: Optional[Any] = None,
) -> StrawberryField:
...
) -> StrawberryField: ...


def field(
Expand Down
24 changes: 8 additions & 16 deletions strawberry/federation/object_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ def type(
requires_scopes: Optional[List[List[str]]] = None,
shareable: bool = False,
tags: Iterable[str] = (),
) -> T:
...
) -> T: ...


@overload
Expand All @@ -137,8 +136,7 @@ def type(
requires_scopes: Optional[List[List[str]]] = None,
shareable: bool = False,
tags: Iterable[str] = (),
) -> Callable[[T], T]:
...
) -> Callable[[T], T]: ...


def type(
Expand Down Expand Up @@ -186,8 +184,7 @@ def input(
directives: Sequence[object] = (),
inaccessible: bool = UNSET,
tags: Iterable[str] = (),
) -> T:
...
) -> T: ...


@overload
Expand All @@ -203,8 +200,7 @@ def input(
directives: Sequence[object] = (),
inaccessible: bool = UNSET,
tags: Iterable[str] = (),
) -> Callable[[T], T]:
...
) -> Callable[[T], T]: ...


def input(
Expand Down Expand Up @@ -245,8 +241,7 @@ def interface(
policy: Optional[List[List[str]]] = None,
requires_scopes: Optional[List[List[str]]] = None,
tags: Iterable[str] = (),
) -> T:
...
) -> T: ...


@overload
Expand All @@ -266,8 +261,7 @@ def interface(
policy: Optional[List[List[str]]] = None,
requires_scopes: Optional[List[List[str]]] = None,
tags: Iterable[str] = (),
) -> Callable[[T], T]:
...
) -> Callable[[T], T]: ...


def interface(
Expand Down Expand Up @@ -316,8 +310,7 @@ def interface_object(
policy: Optional[List[List[str]]] = None,
requires_scopes: Optional[List[List[str]]] = None,
tags: Iterable[str] = (),
) -> T:
...
) -> T: ...


@overload
Expand All @@ -337,8 +330,7 @@ def interface_object(
policy: Optional[List[List[str]]] = None,
requires_scopes: Optional[List[List[str]]] = None,
tags: Iterable[str] = (),
) -> Callable[[T], T]:
...
) -> Callable[[T], T]: ...


def interface_object(
Expand Down
6 changes: 2 additions & 4 deletions strawberry/federation/scalar.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ def scalar(
policy: Optional[List[List[str]]] = None,
requires_scopes: Optional[List[List[str]]] = None,
tags: Optional[Iterable[str]] = (),
) -> Callable[[_T], _T]:
...
) -> Callable[[_T], _T]: ...


@overload
Expand All @@ -60,8 +59,7 @@ def scalar(
policy: Optional[List[List[str]]] = None,
requires_scopes: Optional[List[List[str]]] = None,
tags: Optional[Iterable[str]] = (),
) -> _T:
...
) -> _T: ...


def scalar(
Expand Down
9 changes: 3 additions & 6 deletions strawberry/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,7 @@ def field(
directives: Optional[Sequence[object]] = (),
extensions: Optional[List[FieldExtension]] = None,
graphql_type: Optional[Any] = None,
) -> T:
...
) -> T: ...


@overload
Expand All @@ -451,8 +450,7 @@ def field(
directives: Optional[Sequence[object]] = (),
extensions: Optional[List[FieldExtension]] = None,
graphql_type: Optional[Any] = None,
) -> Any:
...
) -> Any: ...


@overload
Expand All @@ -470,8 +468,7 @@ def field(
directives: Optional[Sequence[object]] = (),
extensions: Optional[List[FieldExtension]] = None,
graphql_type: Optional[Any] = None,
) -> StrawberryField:
...
) -> StrawberryField: ...


def field(
Expand Down
Loading

0 comments on commit 3edf95d

Please sign in to comment.