Skip to content

Commit

Permalink
check for generics in typing
Browse files Browse the repository at this point in the history
  • Loading branch information
fefe982 committed Jan 29, 2024
1 parent 1198938 commit 4bb6ed7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/typeguard/_checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,8 @@ def check_class(
memo: TypeCheckMemo,
) -> None:
if not isclass(value) and not (
sys.version_info >= (3, 11) and isinstance(value, types.GenericAlias)
(sys.version_info >= (3, 11) and isinstance(value, types.GenericAlias)) or
isinstance(value, type(Type)) or isinstance(value, type(Type[Any]))
):
raise TypeCheckError("is not a class")

Expand Down
2 changes: 2 additions & 0 deletions tests/test_checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,8 @@ def test_union_typevar(self):
def test_generic_aliase(self):
if sys.version_info >= (3, 9):
check_type(dict[str, str], type)
check_type(Dict, Type[Any])
check_type(Dict[str, str], Type[Any])


class TestIO:
Expand Down

0 comments on commit 4bb6ed7

Please sign in to comment.