Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 23, 2023
1 parent c9a3715 commit 60a0248
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions dargs/dargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,17 @@ def I(self):
return Argument("_", dict, [self])

def _reorg_dtype(self):
if isinstance(self.dtype, type) or isinstance(get_origin(self.dtype), type) or self.dtype is None:
if (
isinstance(self.dtype, type)
or isinstance(get_origin(self.dtype), type)
or self.dtype is None
):
self.dtype = [self.dtype]
# remove duplicate
self.dtype = {dt if type(dt) is type or type(get_origin(dt)) is type else type(dt) for dt in self.dtype}
self.dtype = {
dt if type(dt) is type or type(get_origin(dt)) is type else type(dt)
for dt in self.dtype
}
# check conner cases
if self.sub_fields or self.sub_variants:
self.dtype.add(list if self.repeat else dict)
Expand Down Expand Up @@ -415,7 +422,11 @@ def _check_exist(self, argdict: dict, path=None):

def _check_data(self, value: Any, path=None):
try:
typeguard.check_type(value, self.dtype, collection_check_strategy=typeguard.CollectionCheckStrategy.ALL_ITEMS)
typeguard.check_type(
value,
self.dtype,
collection_check_strategy=typeguard.CollectionCheckStrategy.ALL_ITEMS,
)
except typeguard.TypeCheckError as e:
raise ArgumentTypeError(
path,
Expand Down

0 comments on commit 60a0248

Please sign in to comment.