Skip to content

Commit

Permalink
chore: Bump ruff to 0.8.0 (#3873)
Browse files Browse the repository at this point in the history
  • Loading branch information
provinzkraut authored Nov 24, 2024
1 parent 7194dcf commit 58ae5d9
Show file tree
Hide file tree
Showing 100 changed files with 209 additions and 212 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ repos:
hooks:
- id: unasyncd
additional_dependencies: ["ruff"]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.7.4"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.8.0"
hooks:
- id: ruff
args: ["--fix"]
Expand Down
2 changes: 1 addition & 1 deletion litestar/_kwargs/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class DependencyCleanupGroup:
exceptions caught in this manner will be re-raised after they have been thrown in the generators.
"""

__slots__ = ("_generators", "_closed")
__slots__ = ("_closed", "_generators")

def __init__(self, generators: list[AnyGenerator] | None = None) -> None:
"""Initialize ``DependencyCleanupGroup``.
Expand Down
2 changes: 1 addition & 1 deletion litestar/_kwargs/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class Dependency:
"""Dependency graph of a given combination of ``Route`` + ``RouteHandler``"""

__slots__ = ("key", "provide", "dependencies")
__slots__ = ("dependencies", "key", "provide")

def __init__(self, key: str, provide: Provide, dependencies: list[Dependency]) -> None:
"""Initialize a dependency.
Expand Down
6 changes: 3 additions & 3 deletions litestar/_openapi/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ def handle_schema_path_not_found(path: str = "/") -> Response:

class OpenAPIPlugin(InitPluginProtocol, ReceiveRoutePlugin):
__slots__ = (
"app",
"included_routes",
"_openapi_config",
"_openapi",
"_openapi_config",
"_openapi_schema",
"app",
"included_routes",
)

def __init__(self, app: Litestar) -> None:
Expand Down
7 changes: 3 additions & 4 deletions litestar/_openapi/schema_generation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
from litestar.typing import FieldDefinition

__all__ = (
"_type_or_first_not_none_inner_type",
"_should_create_enum_schema",
"_should_create_literal_schema",
"_type_or_first_not_none_inner_type",
)


Expand Down Expand Up @@ -75,9 +75,8 @@ def _should_create_literal_schema(field_definition: FieldDefinition) -> bool:
Returns:
A boolean
"""
return (
field_definition.is_literal
or field_definition.is_optional
return field_definition.is_literal or (
field_definition.is_optional
and all(inner.is_literal for inner in field_definition.inner_types if not inner.is_none_type)
)

Expand Down
2 changes: 1 addition & 1 deletion litestar/_openapi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from litestar.types import Method


__all__ = ("default_operation_id_creator", "SEPARATORS_CLEANUP_PATTERN")
__all__ = ("SEPARATORS_CLEANUP_PATTERN", "default_operation_id_creator")

SEPARATORS_CLEANUP_PATTERN = re.compile(r"[!#$%&'*+\-.^_`|~:]+")

Expand Down
2 changes: 1 addition & 1 deletion litestar/_signature/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from litestar.utils.signature import ParsedSignature


__all__ = ("_validate_signature_dependencies", "_normalize_annotation", "_get_decoder_for_type")
__all__ = ("_get_decoder_for_type", "_normalize_annotation", "_validate_signature_dependencies")


def _validate_signature_dependencies(
Expand Down
12 changes: 6 additions & 6 deletions litestar/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
from litestar.types.callable_types import LifespanHook


__all__ = ("HandlerIndex", "Litestar", "DEFAULT_OPENAPI_CONFIG")
__all__ = ("DEFAULT_OPENAPI_CONFIG", "HandlerIndex", "Litestar")

DEFAULT_OPENAPI_CONFIG = OpenAPIConfig(title="Litestar API", version="1.0.0")
"""The default OpenAPI config used if not configuration is explicitly passed to the
Expand Down Expand Up @@ -136,12 +136,11 @@ class Litestar(Router):
"""

__slots__ = (
"_lifespan_managers",
"_server_lifespan_managers",
"_debug",
"_lifespan_managers",
"_openapi_schema",
"_server_lifespan_managers",
"_static_files_config",
"plugins",
"after_exception",
"allowed_hosts",
"asgi_handler",
Expand All @@ -151,20 +150,21 @@ class Litestar(Router):
"cors_config",
"csrf_config",
"event_emitter",
"experimental_features",
"get_logger",
"logger",
"logging_config",
"multipart_form_part_limit",
"on_shutdown",
"on_startup",
"openapi_config",
"pdb_on_exception",
"plugins",
"response_cache_config",
"route_map",
"state",
"stores",
"template_engine",
"pdb_on_exception",
"experimental_features",
)

def __init__(
Expand Down
4 changes: 2 additions & 2 deletions litestar/background_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class BackgroundTask:
Background tasks are called once a Response finishes.
"""

__slots__ = ("fn", "args", "kwargs")
__slots__ = ("args", "fn", "kwargs")

def __init__(self, fn: Callable[P, Any], *args: P.args, **kwargs: P.kwargs) -> None:
"""Initialize ``BackgroundTask``.
Expand Down Expand Up @@ -46,7 +46,7 @@ class BackgroundTasks:
Background tasks are called once a Response finishes.
"""

__slots__ = ("tasks", "run_in_task_group")
__slots__ = ("run_in_task_group", "tasks")

def __init__(self, tasks: Iterable[BackgroundTask], run_in_task_group: bool = False) -> None:
"""Initialize ``BackgroundTasks``.
Expand Down
2 changes: 1 addition & 1 deletion litestar/channels/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
from .plugin import ChannelsPlugin
from .subscriber import Subscriber

__all__ = ("ChannelsPlugin", "ChannelsBackend", "Subscriber")
__all__ = ("ChannelsBackend", "ChannelsPlugin", "Subscriber")
4 changes: 2 additions & 2 deletions litestar/cli/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@


__all__ = (
"UVICORN_INSTALLED",
"JSBEAUTIFIER_INSTALLED",
"LoadedApp",
"UVICORN_INSTALLED",
"LitestarCLIException",
"LitestarEnv",
"LitestarExtensionGroup",
"LitestarGroup",
"LoadedApp",
"show_app_info",
)

Expand Down
6 changes: 3 additions & 3 deletions litestar/concurrency.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@


__all__ = (
"sync_to_thread",
"set_asyncio_executor",
"get_asyncio_executor",
"set_trio_capacity_limiter",
"get_trio_capacity_limiter",
"set_asyncio_executor",
"set_trio_capacity_limiter",
"sync_to_thread",
)


Expand Down
2 changes: 1 addition & 1 deletion litestar/config/response_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from litestar.stores.base import Store
from litestar.types import CacheKeyBuilder, HTTPScope

__all__ = ("ResponseCacheConfig", "default_cache_key_builder", "CACHE_FOREVER")
__all__ = ("CACHE_FOREVER", "ResponseCacheConfig", "default_cache_key_builder")


@final
Expand Down
12 changes: 6 additions & 6 deletions litestar/connection/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ class ASGIConnection(Generic[HandlerT, UserT, AuthT, StateT]):
"""The base ASGI connection container."""

__slots__ = (
"scope",
"receive",
"send",
"_base_url",
"_url",
"_parsed_query",
"_connection_state",
"_cookies",
"_parsed_query",
"_server_extensions",
"_connection_state",
"_url",
"receive",
"scope",
"send",
)

scope: Scope
Expand Down
10 changes: 5 additions & 5 deletions litestar/connection/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ class Request(Generic[UserT, AuthT, StateT], ASGIConnection["HTTPRouteHandler",
"""The Litestar Request class."""

__slots__ = (
"_json",
"_form",
"_body",
"_msgpack",
"_content_type",
"_accept",
"_body",
"_content_length",
"_content_type",
"_form",
"_json",
"_msgpack",
"is_connected",
"supports_push_promise",
)
Expand Down
2 changes: 1 addition & 1 deletion litestar/contrib/htmx/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from litestar.utils import warn_deprecation

if TYPE_CHECKING:
from litestar_htmx._utils import ( # noqa: TCH004
from litestar_htmx._utils import ( # noqa: TC004
HTMXHeaders,
get_headers,
get_location_headers,
Expand Down
2 changes: 1 addition & 1 deletion litestar/contrib/htmx/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from litestar.utils import warn_deprecation

if TYPE_CHECKING:
from litestar_htmx import ( # noqa: TCH004
from litestar_htmx import ( # noqa: TC004
HTMXDetails,
HTMXRequest,
)
Expand Down
2 changes: 1 addition & 1 deletion litestar/contrib/htmx/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from litestar.utils import warn_deprecation

if TYPE_CHECKING:
from litestar_htmx import ( # noqa: TCH004
from litestar_htmx import ( # noqa: TC004
ClientRedirect,
ClientRefresh,
HTMXTemplate,
Expand Down
2 changes: 1 addition & 1 deletion litestar/contrib/htmx/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from litestar.utils import warn_deprecation

if TYPE_CHECKING:
from litestar_htmx import HtmxHeaderType, LocationType, TriggerEventType # noqa: TCH004
from litestar_htmx import HtmxHeaderType, LocationType, TriggerEventType # noqa: TC004
__all__ = (
"HtmxHeaderType",
"LocationType",
Expand Down
2 changes: 1 addition & 1 deletion litestar/contrib/opentelemetry/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class OpenTelemetryPlugin(InitPluginProtocol):
"""OpenTelemetry Plugin."""

__slots__ = ("config", "_middleware")
__slots__ = ("_middleware", "config")

def __init__(self, config: OpenTelemetryConfig | None = None) -> None:
self.config = config or OpenTelemetryConfig()
Expand Down
2 changes: 1 addition & 1 deletion litestar/contrib/prometheus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from litestar.utils import warn_deprecation

__all__ = ("PrometheusMiddleware", "PrometheusConfig", "PrometheusController")
__all__ = ("PrometheusConfig", "PrometheusController", "PrometheusMiddleware")


def __getattr__(attr_name: str) -> object:
Expand Down
4 changes: 2 additions & 2 deletions litestar/contrib/pydantic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
from litestar.utils import warn_deprecation

__all__ = (
"PydanticDIPlugin",
"PydanticDTO",
"PydanticInitPlugin",
"PydanticSchemaPlugin",
"PydanticPlugin",
"PydanticDIPlugin",
"PydanticSchemaPlugin",
)


Expand Down
2 changes: 1 addition & 1 deletion litestar/contrib/sqlalchemy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from litestar.utils import warn_deprecation

__all__ = (
"ModelT",
"SQLAlchemyAsyncRepository",
"SQLAlchemySyncRepository",
"ModelT",
"wrap_sqlalchemy_exception",
)

Expand Down
4 changes: 2 additions & 2 deletions litestar/contrib/sqlalchemy/plugins/init/config/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from litestar.utils import warn_deprecation

__all__ = (
"SQLAlchemyAsyncConfig",
"AlembicAsyncConfig",
"AsyncSessionConfig",
"default_before_send_handler",
"SQLAlchemyAsyncConfig",
"autocommit_before_send_handler",
"default_before_send_handler",
)


Expand Down
2 changes: 1 addition & 1 deletion litestar/contrib/sqlalchemy/plugins/init/config/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
__all__ = (
"SESSION_SCOPE_KEY",
"SESSION_TERMINUS_ASGI_EVENTS",
"GenericAlembicConfig",
"GenericSQLAlchemyConfig",
"GenericSessionConfig",
"GenericAlembicConfig",
)


Expand Down
4 changes: 2 additions & 2 deletions litestar/contrib/sqlalchemy/plugins/init/config/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from litestar.utils import warn_deprecation

__all__ = (
"SQLAlchemySyncConfig",
"AlembicSyncConfig",
"SQLAlchemySyncConfig",
"SyncSessionConfig",
"default_before_send_handler",
"autocommit_before_send_handler",
"default_before_send_handler",
)


Expand Down
2 changes: 1 addition & 1 deletion litestar/contrib/sqlalchemy/repository/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from litestar.utils import warn_deprecation

__all__ = (
"ModelT",
"SQLAlchemyAsyncRepository",
"SQLAlchemySyncRepository",
"ModelT",
"wrap_sqlalchemy_exception",
)

Expand Down
2 changes: 1 addition & 1 deletion litestar/contrib/sqlalchemy/repository/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from litestar.utils import warn_deprecation

__all__ = (
"wrap_sqlalchemy_exception",
"get_instrumented_attr",
"wrap_sqlalchemy_exception",
)


Expand Down
4 changes: 2 additions & 2 deletions litestar/contrib/sqlalchemy/repository/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

__all__ = (
"ModelT",
"SelectT",
"RowT",
"SQLAlchemySyncRepositoryT",
"SQLAlchemyAsyncRepositoryT",
"SQLAlchemySyncRepositoryT",
"SelectT",
)


Expand Down
2 changes: 1 addition & 1 deletion litestar/contrib/sqlalchemy/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
__all__ = (
"GUID",
"ORA_JSONB",
"DateTimeUTC",
"BigIntIdentity",
"DateTimeUTC",
"JsonB",
)

Expand Down
Loading

0 comments on commit 58ae5d9

Please sign in to comment.