Skip to content

Commit

Permalink
Fix mypy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Fatal1ty committed Nov 14, 2023
1 parent e054a06 commit 32a4911
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
31 changes: 12 additions & 19 deletions mashumaro/core/meta/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,28 +746,21 @@ def is_hashable_type(typ: Any) -> bool:
return True


if PY_39_MIN:

def str_to_forward_ref(
annotation: str, module: Optional[str] = None
) -> ForwardRef:
def str_to_forward_ref(
annotation: str, module: Optional[types.ModuleType] = None
) -> ForwardRef:
if PY_39_MIN:
return ForwardRef(annotation, module=module)
else:
return ForwardRef(annotation)

def evaluate_forward_ref(
typ: ForwardRef, globalns: Any, localns: Any
) -> Optional[Type]:

def evaluate_forward_ref(
typ: ForwardRef, globalns: Any, localns: Any
) -> Optional[Type]:
if PY_39_MIN:
return typ._evaluate(
globalns, localns, frozenset()
) # type: ignore[call-arg]

else:

def str_to_forward_ref(
annotation: str, _: Optional[str] = None
) -> ForwardRef:
return ForwardRef(annotation)

def evaluate_forward_ref(
typ: ForwardRef, globalns: Any, localns: Any
) -> Optional[Type]:
else:
return typ._evaluate(globalns, localns) # type: ignore[call-arg]
2 changes: 1 addition & 1 deletion mashumaro/core/meta/types/pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def _pack_with_annotated_serialization_strategy(
value_type, spec.origin_type
)
value_type = substitute_type_params(
value_type,
value_type, # type: ignore
resolve_type_params(strategy_type, get_args(spec.type))[strategy_type],
)
overridden_fn = f"__{spec.field_ctx.name}_serialize_{random_hex()}"
Expand Down
2 changes: 1 addition & 1 deletion mashumaro/core/meta/types/unpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ def _unpack_with_annotated_serialization_strategy(
value_type, spec.origin_type
)
value_type = substitute_type_params(
value_type,
value_type, # type: ignore
resolve_type_params(strategy_type, get_args(spec.type))[strategy_type],
)
overridden_fn = f"__{spec.field_ctx.name}_deserialize_{random_hex()}"
Expand Down

0 comments on commit 32a4911

Please sign in to comment.