Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Willi Sontopski authored and LostInDarkMath committed Oct 14, 2022
1 parent 12db86c commit 05771c3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Changelog
## Pedantic 1.12.10
- fix tests

## Pedantic 1.12.9
- bugfix in type checking logic concerning `typing.Awaitable` and `typing.Coroutine` with return type `UnionType`

Expand Down
6 changes: 4 additions & 2 deletions docs/pedantic/type_checking_logic/check_types.html
Original file line number Diff line number Diff line change
Expand Up @@ -584,10 +584,12 @@ <h1 class="title">Module <code>pedantic.type_checking_logic.check_types</code></
python_sub = _get_class_of_type_annotation(sub_type)
python_super = _get_class_of_type_annotation(super_type)

if python_super == typing.Union or isinstance(python_super, types.UnionType):
is_union_type_available = hasattr(types, &#39;UnionType&#39;) # true for Python &gt;= 3.10

if python_super == typing.Union or (is_union_type_available and isinstance(python_super, types.UnionType)):
type_args = get_type_arguments(cls=super_type)

if python_sub == typing.Union or isinstance(python_sub, types.UnionType):
if python_sub == typing.Union or (is_union_type_available and isinstance(python_sub, types.UnionType)):
sub_type_args = get_type_arguments(cls=sub_type)
return all([x in type_args for x in sub_type_args])

Expand Down
6 changes: 4 additions & 2 deletions pedantic/type_checking_logic/check_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,10 +555,12 @@ def _is_subtype(sub_type: Any, super_type: Any) -> bool:
python_sub = _get_class_of_type_annotation(sub_type)
python_super = _get_class_of_type_annotation(super_type)

if python_super == typing.Union or isinstance(python_super, types.UnionType):
is_union_type_available = hasattr(types, 'UnionType') # true for Python >= 3.10

if python_super == typing.Union or (is_union_type_available and isinstance(python_super, types.UnionType)):
type_args = get_type_arguments(cls=super_type)

if python_sub == typing.Union or isinstance(python_sub, types.UnionType):
if python_sub == typing.Union or (is_union_type_available and isinstance(python_sub, types.UnionType)):
sub_type_args = get_type_arguments(cls=sub_type)
return all([x in type_args for x in sub_type_args])

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def get_content_from_readme(file_name: str = 'README.md') -> str:

setup(
name="pedantic",
version="1.12.9",
version="1.12.10",
python_requires='>=3.7.0',
packages=find_packages(),
install_requires=[],
Expand Down

0 comments on commit 05771c3

Please sign in to comment.