From eb69726d1aa5cdfe3be048aeea8a737f50a62fcc Mon Sep 17 00:00:00 2001 From: tarsil Date: Mon, 29 Jan 2024 16:12:32 +0000 Subject: [PATCH] Fix linting --- docs_src/tips/settings.py | 1 + saffier/cli/cli.py | 1 + saffier/cli/operations/branches.py | 1 - saffier/cli/operations/list_templates.py | 1 + saffier/contrib/multi_tenancy/exceptions.py | 3 +- saffier/core/db/models/metaclasses.py | 6 +- saffier/exceptions.py | 39 ++++------ saffier/protocols/many_relationship.py | 6 +- saffier/protocols/queryset.py | 80 ++++++++------------- tests/prefetch/test_prefetch_object.py | 3 +- tests/signals/test_signals.py | 3 +- 11 files changed, 51 insertions(+), 93 deletions(-) diff --git a/docs_src/tips/settings.py b/docs_src/tips/settings.py index 76f0467..8d3d9af 100644 --- a/docs_src/tips/settings.py +++ b/docs_src/tips/settings.py @@ -1,6 +1,7 @@ """ Generated by 'esmerald-admin createproject' """ + from functools import cached_property from typing import Optional, Tuple diff --git a/saffier/cli/cli.py b/saffier/cli/cli.py index 2b37acd..9800ef2 100644 --- a/saffier/cli/cli.py +++ b/saffier/cli/cli.py @@ -1,6 +1,7 @@ """ Client to interact with Saffier models and migrations. """ + import inspect import sys import typing diff --git a/saffier/cli/operations/branches.py b/saffier/cli/operations/branches.py index dff7a03..683d8a4 100644 --- a/saffier/cli/operations/branches.py +++ b/saffier/cli/operations/branches.py @@ -2,7 +2,6 @@ Client to interact with Saffier models and migrations. """ - import click from saffier.cli.base import branches as _branches diff --git a/saffier/cli/operations/list_templates.py b/saffier/cli/operations/list_templates.py index e6db58c..923393b 100644 --- a/saffier/cli/operations/list_templates.py +++ b/saffier/cli/operations/list_templates.py @@ -1,6 +1,7 @@ """ Client to interact with Saffier models and migrations. """ + import click from saffier.cli.base import list_templates as template_list diff --git a/saffier/contrib/multi_tenancy/exceptions.py b/saffier/contrib/multi_tenancy/exceptions.py index 9bc39fe..f02f3bb 100644 --- a/saffier/contrib/multi_tenancy/exceptions.py +++ b/saffier/contrib/multi_tenancy/exceptions.py @@ -1,5 +1,4 @@ from saffier.exceptions import SaffierException -class ModelSchemaError(SaffierException): - ... +class ModelSchemaError(SaffierException): ... diff --git a/saffier/core/db/models/metaclasses.py b/saffier/core/db/models/metaclasses.py index db6eeee..19c0609 100644 --- a/saffier/core/db/models/metaclasses.py +++ b/saffier/core/db/models/metaclasses.py @@ -495,9 +495,7 @@ def __new__(cls, name: str, bases: Tuple[Type, ...], attrs: Any) -> Any: return new_model -class ModelMeta(metaclass=BaseModelMeta): - ... +class ModelMeta(metaclass=BaseModelMeta): ... -class ReflectMeta(metaclass=BaseModelReflectMeta): - ... +class ReflectMeta(metaclass=BaseModelReflectMeta): ... diff --git a/saffier/exceptions.py b/saffier/exceptions.py index 69ac618..9167405 100644 --- a/saffier/exceptions.py +++ b/saffier/exceptions.py @@ -21,56 +21,43 @@ def __str__(self) -> str: return "".join(self.args).strip() -class ObjectNotFound(SaffierException): - ... +class ObjectNotFound(SaffierException): ... DoesNotFound = ObjectNotFound -class MultipleObjectsReturned(SaffierException): - ... +class MultipleObjectsReturned(SaffierException): ... -class ValidationError(BaseError): - ... +class ValidationError(BaseError): ... -class ImproperlyConfigured(SaffierException): - ... +class ImproperlyConfigured(SaffierException): ... -class ForeignKeyBadConfigured(SaffierException): - ... +class ForeignKeyBadConfigured(SaffierException): ... -class RelationshipIncompatible(SaffierException): - ... +class RelationshipIncompatible(SaffierException): ... -class DuplicateRecordError(SaffierException): - ... +class DuplicateRecordError(SaffierException): ... -class RelationshipNotFound(SaffierException): - ... +class RelationshipNotFound(SaffierException): ... -class QuerySetError(SaffierException): - ... +class QuerySetError(SaffierException): ... -class ModelReferenceError(SaffierException): - ... +class ModelReferenceError(SaffierException): ... -class SchemaError(SaffierException): - ... +class SchemaError(SaffierException): ... -class SignalError(SaffierException): - ... +class SignalError(SaffierException): ... -class CommandEnvironmentError(SaffierException): - ... +class CommandEnvironmentError(SaffierException): ... diff --git a/saffier/protocols/many_relationship.py b/saffier/protocols/many_relationship.py index 1985bcc..9599f84 100644 --- a/saffier/protocols/many_relationship.py +++ b/saffier/protocols/many_relationship.py @@ -14,8 +14,6 @@ class ManyRelationProtocol(Protocol): """Defines the what needs to be implemented when using the ManyRelationProtocol""" - async def add(self, child: "Model") -> None: - ... + async def add(self, child: "Model") -> None: ... - async def remove(self, child: "Model") -> None: - ... + async def remove(self, child: "Model") -> None: ... diff --git a/saffier/protocols/queryset.py b/saffier/protocols/queryset.py index d09779d..e562217 100644 --- a/saffier/protocols/queryset.py +++ b/saffier/protocols/queryset.py @@ -27,68 +27,47 @@ class QuerySetProtocol(Protocol): """Defines the what needs to be implemented when using the ManyRelationProtocol""" - def filter(self, **kwargs: Any) -> "QuerySet": - ... + def filter(self, **kwargs: Any) -> "QuerySet": ... - def exclude(self, **kwargs: "Model") -> "QuerySet": - ... + def exclude(self, **kwargs: "Model") -> "QuerySet": ... - def lookup(self, **kwargs: Any) -> "QuerySet": - ... + def lookup(self, **kwargs: Any) -> "QuerySet": ... - def order_by(self, columns: Union[List, str]) -> "QuerySet": - ... + def order_by(self, columns: Union[List, str]) -> "QuerySet": ... - def limit(self, limit_count: int) -> "QuerySet": - ... + def limit(self, limit_count: int) -> "QuerySet": ... - def offset(self, offset: int) -> "QuerySet": - ... + def offset(self, offset: int) -> "QuerySet": ... - def group_by(self, group_by: Union[List, str]) -> "QuerySet": - ... + def group_by(self, group_by: Union[List, str]) -> "QuerySet": ... - def distinct(self, distinct_on: Union[List, str]) -> "QuerySet": - ... + def distinct(self, distinct_on: Union[List, str]) -> "QuerySet": ... - def select_related(self, related: Union[List, str]) -> "QuerySet": - ... + def select_related(self, related: Union[List, str]) -> "QuerySet": ... - async def exists(self) -> bool: - ... + async def exists(self) -> bool: ... - async def count(self) -> int: - ... + async def count(self) -> int: ... - async def get_or_none(self, **kwargs: Any) -> Union[SaffierModel, None]: - ... + async def get_or_none(self, **kwargs: Any) -> Union[SaffierModel, None]: ... - async def all(self, **kwargs: Any) -> Sequence[Optional[SaffierModel]]: - ... + async def all(self, **kwargs: Any) -> Sequence[Optional[SaffierModel]]: ... - async def get(self, **kwargs: Any) -> SaffierModel: - ... + async def get(self, **kwargs: Any) -> SaffierModel: ... - async def first(self, **kwargs: Any) -> Union[SaffierModel, None]: - ... + async def first(self, **kwargs: Any) -> Union[SaffierModel, None]: ... - async def last(self, **kwargs: Any) -> Union[SaffierModel, None]: - ... + async def last(self, **kwargs: Any) -> Union[SaffierModel, None]: ... - async def create(self, **kwargs: Any) -> SaffierModel: - ... + async def create(self, **kwargs: Any) -> SaffierModel: ... - async def bulk_create(self, objs: Sequence[List[Dict[Any, Any]]]) -> None: - ... + async def bulk_create(self, objs: Sequence[List[Dict[Any, Any]]]) -> None: ... - async def bulk_update(self, objs: Sequence[List[SaffierModel]], fields: List[str]) -> None: - ... + async def bulk_update(self, objs: Sequence[List[SaffierModel]], fields: List[str]) -> None: ... - async def delete(self) -> None: - ... + async def delete(self) -> None: ... - async def update(self, **kwargs: Any) -> None: - ... + async def update(self, **kwargs: Any) -> None: ... async def values( self, @@ -97,8 +76,7 @@ async def values( exclude_none: bool, flatten: bool, **kwargs: Any, - ) -> List[Any]: - ... + ) -> List[Any]: ... async def values_list( self, @@ -106,18 +84,16 @@ async def values_list( exclude: Union[Sequence[str], Set[str]], exclude_none: bool, flat: bool, - ) -> List[Any]: - ... + ) -> List[Any]: ... async def get_or_create( self, _defaults: Optional[Dict[str, Any]] = None, **kwargs: Any, - ) -> Tuple[SaffierModel, bool]: - ... + ) -> Tuple[SaffierModel, bool]: ... - async def update_or_create(self, defaults: Any, **kwargs: Any) -> Tuple[SaffierModel, bool]: - ... + async def update_or_create( + self, defaults: Any, **kwargs: Any + ) -> Tuple[SaffierModel, bool]: ... - async def contains(self, instance: SaffierModel) -> bool: - ... + async def contains(self, instance: SaffierModel) -> bool: ... diff --git a/tests/prefetch/test_prefetch_object.py b/tests/prefetch/test_prefetch_object.py index 0fdf926..85b4dc5 100644 --- a/tests/prefetch/test_prefetch_object.py +++ b/tests/prefetch/test_prefetch_object.py @@ -48,8 +48,7 @@ async def rollback_connections(): yield -class Test: - ... +class Test: ... async def test_raise_prefetch_related_error(): diff --git a/tests/signals/test_signals.py b/tests/signals/test_signals.py index f2d0512..aec88db 100644 --- a/tests/signals/test_signals.py +++ b/tests/signals/test_signals.py @@ -68,8 +68,7 @@ def test_passing_no_kwargs(): with pytest.raises(SignalError): @pre_save(User) - def execute(sender, instance): - ... + def execute(sender, instance): ... def test_invalid_signal():