Skip to content

Commit 6289629

Browse files
committed
add Validate decorators.
1 parent 5b95e0b commit 6289629

File tree

4 files changed

+5
-9
lines changed

4 files changed

+5
-9
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ check-overridden = true
6969
check-property-returns = true
7070
check-protected = true
7171
check-protected-class-methods = true
72-
disable = ["SIG101"]
72+
disable = ["SIG101", "SIG501"]
7373

7474
[tool.setuptools.packages.find]
7575
include = ["db_first*"]

src/db_first/decorators/validation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
class Validation:
1010
@classmethod
1111
def input(
12-
cls, schema: SchemaMeta, deserialize: bool = True, keys: Iterable[str] | None = None
12+
cls, schema: SchemaMeta, deserialize: bool = True, keys: Iterable[str] or None = None
1313
) -> Callable:
1414
def decorator(func: Callable) -> Callable:
1515
@wraps(func)
@@ -27,7 +27,7 @@ def wrapper(self, **data) -> Any:
2727

2828
@classmethod
2929
def output(
30-
cls, schema: SchemaMeta, serialize: bool = False, keys: Iterable[str] | None = None
30+
cls, schema: SchemaMeta, serialize: bool = False, keys: Iterable[str] or None = None
3131
) -> Callable:
3232
def decorator(func: Callable) -> Callable:
3333
@wraps(func)

src/db_first/schemas/base.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Any
2-
31
from marshmallow import post_dump
42
from marshmallow import Schema
53

@@ -9,9 +7,7 @@ class BaseSchema(Schema):
97
__skipped_keys__ = ()
108

119
@post_dump()
12-
def _delete_keys_with_empty_value(
13-
self, data, many=False
14-
) -> dict[Any, dict] | list[dict] | dict | list:
10+
def _delete_keys_with_empty_value(self, data, many=False) -> dict or list:
1511
"""Clearing hierarchical structures from empty values.
1612
1713
Cleaning occurs for objects of the list and dict types, other types do not clean.

tests/test_crud_mixin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from sqlalchemy.orm import Mapped
1111
from sqlalchemy.orm import mapped_column
1212

13-
from .conftest import UNIQUE_STRING
1413
from src.db_first import BaseCRUD
1514
from src.db_first import ModelMixin
1615
from src.db_first.decorators import Validation
@@ -20,6 +19,7 @@
2019
from src.db_first.mixins.crud import DeleteMixin
2120
from src.db_first.mixins.crud import ReadMixin
2221
from src.db_first.mixins.crud import UpdateMixin
22+
from tests.conftest import UNIQUE_STRING
2323

2424

2525
class TestSchema(Schema):

0 commit comments

Comments
 (0)