Skip to content

Remove obsolete typeguard checks #274

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions marshmallow_dataclass/union_field.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,13 @@
import copy
import inspect
from typing import List, Tuple, Any, Optional

import typeguard
from typeguard import TypeCheckError
from marshmallow import fields, Schema, ValidationError

try:
from typeguard import TypeCheckError # type: ignore[attr-defined]
except ImportError:
# typeguard < 3
TypeCheckError = TypeError # type: ignore[misc, assignment]

if "argname" not in inspect.signature(typeguard.check_type).parameters:

def _check_type(value, expected_type, argname: str):
return typeguard.check_type(value=value, expected_type=expected_type)

else:
# typeguard < 3.0.0rc2
def _check_type(value, expected_type, argname: str):
return typeguard.check_type( # type: ignore[call-overload]
value=value, expected_type=expected_type, argname=argname
)
def _check_type(value, expected_type, argname: str):
return typeguard.check_type(value=value, expected_type=expected_type)


class Union(fields.Field):
Expand Down