Skip to content

Commit 7c20fb9

Browse files
committed
Fix linter warnings
1 parent e301c82 commit 7c20fb9

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

marshmallow_dataclass/__init__.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def add_schema(_cls=None, base_schema=None):
166166
This decorator adds a marshmallow schema as the 'Schema' attribute in a dataclass.
167167
It uses :func:`class_schema` internally.
168168
169-
:param type cls: The dataclass to which a Schema should be added
169+
:param type _cls: The dataclass to which a Schema should be added
170170
:param base_schema: marshmallow schema used as a base class when deriving dataclass schema
171171
172172
>>> class BaseSchema(marshmallow.Schema):
@@ -183,6 +183,7 @@ def add_schema(_cls=None, base_schema=None):
183183
"""
184184

185185
def decorator(clazz: Type[_U]) -> Type[_U]:
186+
# noinspection PyTypeHints
186187
clazz.Schema = class_schema(clazz, base_schema) # type: ignore
187188
return clazz
188189

@@ -304,7 +305,7 @@ def class_schema(
304305

305306
@lru_cache(maxsize=MAX_CLASS_SCHEMA_CACHE_SIZE)
306307
def _internal_class_schema(
307-
clazz: type, base_schema: Optional[Type[marshmallow.Schema]] = None
308+
clazz: type, base_schema: Optional[Type[marshmallow.Schema]] = None
308309
) -> Type[marshmallow.Schema]:
309310
try:
310311
# noinspection PyDataclass
@@ -313,12 +314,13 @@ def _internal_class_schema(
313314
try:
314315
warnings.warn(
315316
f"marshmallow_dataclass was called on the class {clazz}, which is not a dataclass. "
316-
f"It is going to try and convert the class into a dataclass, which may have undesirable side effects. "
317-
f"To avoid this message, make sure all your classes and all the classes of their fields are either "
318-
f"explicitly supported by marshmallow_datcalass, or are already dataclasses. "
319-
f"For more information, see https://github.com/lovasoa/marshmallow_dataclass/issues/51",
317+
f"It is going to try and convert the class into a dataclass, which may have "
318+
f"undesirable side effects. To avoid this message, make sure all your classes and "
319+
f"all the classes of their fields are either explicitly supported by "
320+
f"marshmallow_datcalass, or are already dataclasses. For more information, see "
321+
f"https://github.com/lovasoa/marshmallow_dataclass/issues/51"
320322
)
321-
created_dataclass = dataclasses.dataclass(clazz)
323+
created_dataclass: type = dataclasses.dataclass(clazz)
322324
return _internal_class_schema(created_dataclass, base_schema)
323325
except Exception:
324326
raise TypeError(
@@ -521,7 +523,7 @@ def field_for_schema(
521523
# Nested dataclasses
522524
forward_reference = getattr(typ, "__forward_arg__", None)
523525
nested = (
524-
nested_schema or forward_reference or _internal_class_schema(typ, base_schema)
526+
nested_schema or forward_reference or _internal_class_schema(typ, base_schema)
525527
)
526528

527529
return marshmallow.fields.Nested(nested, **metadata)
@@ -604,8 +606,11 @@ def new_type(x: _U):
604606
return x
605607

606608
new_type.__name__ = name
609+
# noinspection PyTypeHints
607610
new_type.__supertype__ = typ # type: ignore
611+
# noinspection PyTypeHints
608612
new_type._marshmallow_field = field # type: ignore
613+
# noinspection PyTypeHints
609614
new_type._marshmallow_args = kwargs # type: ignore
610615
return new_type
611616

0 commit comments

Comments
 (0)