Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adriangb committed Jul 25, 2022
1 parent 2b72b3b commit 315d175
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
import sys
from datetime import datetime, timezone
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, Iterator, Type, Union
Expand All @@ -15,7 +16,7 @@
import annotated_types
from annotated_types.test_cases import Case, cases

Constraint = Union[annotated_types.BaseMetadata, slice]
Constraint = Union[annotated_types.BaseMetadata, slice, "re.Pattern[bytes]", "re.Pattern[str]"]


def check_gt(constraint: Constraint, val: Any) -> bool:
Expand Down Expand Up @@ -96,12 +97,10 @@ def get_constraints(tp: type) -> Iterator[Constraint]:
args = iter(get_args(tp))
next(args)
for arg in args:
if isinstance(arg, (annotated_types.BaseMetadata, slice)):
if isinstance(arg, annotated_types.Interval):
for case in arg:
yield case
else:
yield arg
if isinstance(arg, (annotated_types.BaseMetadata, re.Pattern, slice)):
yield arg
elif isinstance(arg, annotated_types.GroupedMetadata):
yield from arg


def is_valid(tp: type, value: Any) -> bool:
Expand Down

0 comments on commit 315d175

Please sign in to comment.