Skip to content

Commit

Permalink
feat: upgrade pre-commit tools version
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxin688 committed Jun 17, 2024
1 parent a326bfb commit c7db26c
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 42 deletions.
6 changes: 3 additions & 3 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.1.13
rev: v0.4.9
hooks:
- id: ruff
args: [--fix]
Expand All @@ -20,12 +20,12 @@ repos:
- id: check-case-conflict
- id: mixed-line-ending
- repo: https://github.com/crate-ci/typos
rev: v1.16.22
rev: v1.22.7
hooks:
- id: typos

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
rev: v3.16.0
hooks:
- id: pyupgrade
args: ["--py312-plus"]
Expand Down
1 change: 1 addition & 0 deletions alembic/versions/2024_05_16_2211-b6b1ccd63fa2_init_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2024-05-16 22:11:27.810000
"""

from collections.abc import Sequence

import sqlalchemy as sa
Expand Down
3 changes: 1 addition & 2 deletions src/core/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,4 @@ class IdResponse(BaseModel):
id: int


class IdCreate(IdResponse):
...
class IdCreate(IdResponse): ...
12 changes: 4 additions & 8 deletions src/core/errors/auth_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,16 @@ def error_message_value_handler(value: Any) -> Any:
return value


class TokenInvalidForRefreshError(Exception):
...
class TokenInvalidForRefreshError(Exception): ...


class TokenInvalidError(Exception):
...
class TokenInvalidError(Exception): ...


class TokenExpireError(Exception):
...
class TokenExpireError(Exception): ...


class PermissionDenyError(Exception):
...
class PermissionDenyError(Exception): ...


class NotFoundError(Exception):
Expand Down
17 changes: 8 additions & 9 deletions src/core/repositories/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ def __init__(self, model: type[ModelT]) -> None:

@overload
@classmethod
def get_id_attribute_value(cls, obj: ModelT, id_attribute: str | None = None) -> PkIdT:
...
def get_id_attribute_value(cls, obj: ModelT, id_attribute: str | None = None) -> PkIdT: ...

@overload
@classmethod
def get_id_attribute_value(cls, obj: type[ModelT], id_attribute: str | None = None) -> InstrumentedAttribute[PkIdT]:
...
def get_id_attribute_value(
cls, obj: type[ModelT], id_attribute: str | None = None
) -> InstrumentedAttribute[PkIdT]: ...

@classmethod
def get_id_attribute_value(
Expand All @@ -109,7 +109,8 @@ def get_id_attribute_value(
return getattr(obj, id_attribute if id_attribute is not None else cls.id_attribute)

def inspect_relationship(self) -> dict[str, type["RelationT"]]:
result: dict[str, type["RelationT"]] = {}
result: dict[str, type[RelationT]] = {}

insp = inspect(self.model)
for relationship in insp.relationships:
key = relationship.key
Expand Down Expand Up @@ -311,12 +312,10 @@ def _apply_list(
return stmt

@overload
def _check_not_found(self, instance: ModelT | None, column: str, value: Any) -> ModelT:
...
def _check_not_found(self, instance: ModelT | None, column: str, value: Any) -> ModelT: ...

@overload
def _check_not_found(self, instance: Row[Any] | None, column: str, value: Any) -> Row[Any]:
...
def _check_not_found(self, instance: Row[Any] | None, column: str, value: Any) -> Row[Any]: ...

def _check_not_found(self, instance: ModelT | Row[Any] | None, column: str, value: Any) -> ModelT | Row[Any]:
"""
Expand Down
21 changes: 7 additions & 14 deletions src/features/admin/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,13 @@ class Permission(BaseModel):
tag: str


class PermissionCreate(BaseModel):
...
class PermissionCreate(BaseModel): ...


class PermissionUpdate(QueryParams):
...
class PermissionUpdate(QueryParams): ...


class PermissionQuery(QueryParams):
...
class PermissionQuery(QueryParams): ...


class UserBase(BaseModel):
Expand Down Expand Up @@ -118,8 +115,7 @@ class MenuUpdate(BaseModel):
parent_id: int | None = None


class MenuQuery(QueryParams):
...
class MenuQuery(QueryParams): ...


class UserCreate(UserBase):
Expand Down Expand Up @@ -176,13 +172,10 @@ class RoleList(RoleBase, AuditTime):
permission_count: int


class UserQuery(QueryParams):
...
class UserQuery(QueryParams): ...


class GroupQuery(QueryParams):
...
class GroupQuery(QueryParams): ...


class RoleQuery(QueryParams):
...
class RoleQuery(QueryParams): ...
6 changes: 2 additions & 4 deletions src/features/admin/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,10 @@ async def get_all(self, session: AsyncSession) -> Sequence[Menu]:
return (await session.scalars(select(self.model))).all()

@staticmethod
def menu_tree_transform(menus: Sequence[Menu]) -> list[dict]:
...
def menu_tree_transform(menus: Sequence[Menu]) -> list[dict]: ...


class GroupRepo(BaseRepository[Group, schemas.GroupCreate, schemas.GroupUpdate, schemas.GroupQuery]):
...
class GroupRepo(BaseRepository[Group, schemas.GroupCreate, schemas.GroupUpdate, schemas.GroupQuery]): ...


class RoleRepo(BaseRepository[Role, schemas.RoleCreate, schemas.RoleUpdate, schemas.RoleQuery]):
Expand Down
3 changes: 1 addition & 2 deletions src/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,4 @@ def get_stoplight_elements_html(
return HTMLResponse(html)


def get_open_api_intro() -> str:
...
def get_open_api_intro() -> str: ...

0 comments on commit c7db26c

Please sign in to comment.