Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

"TypedDict does not support instance and class checks" with Python 3.13 #453

Open
2 tasks done
musicinmybrain opened this issue Apr 15, 2024 · 7 comments
Open
2 tasks done
Labels

Comments

@musicinmybrain
Copy link

Things to check first

  • I have searched the existing issues and didn't find my bug already reported there

  • I have checked that my bug is still present in the latest release

Typeguard version

4.2.1

Python version

3.13.0a5

What happened?

================================================================================================= FAILURES ==================================================================================================
_________________________________________________________________________ TestTypedDict.test_typed_dict[typing_extensions-correct] __________________________________________________________________________
/home/ben/src/forks/typeguard/tests/test_checkers.py:496: in test_typed_dict
    check_type(value, DummyDict)
/home/ben/src/forks/typeguard/src/typeguard/_functions.py:106: in check_type
    check_type_internal(value, expected_type, memo)
/home/ben/src/forks/typeguard/src/typeguard/_checkers.py:783: in check_type_internal
    if not isinstance(value, origin_type):
/home/ben/src/forks/typeguard/_e/lib64/python3.13/site-packages/typing_extensions.py:951: in __subclasscheck__
    raise TypeError('TypedDict does not support instance and class checks')
E   TypeError: TypedDict does not support instance and class checks
________________________________________________________________________ TestTypedDict.test_typed_dict[typing_extensions-missing_x] _________________________________________________________________________
/home/ben/src/forks/typeguard/tests/test_checkers.py:494: in test_typed_dict
    pytest.raises(TypeCheckError, check_type, value, DummyDict).match(error_re)
/home/ben/src/forks/typeguard/src/typeguard/_functions.py:106: in check_type
    check_type_internal(value, expected_type, memo)
/home/ben/src/forks/typeguard/src/typeguard/_checkers.py:783: in check_type_internal
    if not isinstance(value, origin_type):
/home/ben/src/forks/typeguard/_e/lib64/python3.13/site-packages/typing_extensions.py:951: in __subclasscheck__
    raise TypeError('TypedDict does not support instance and class checks')
E   TypeError: TypedDict does not support instance and class checks
_________________________________________________________________________ TestTypedDict.test_typed_dict[typing_extensions-wrong_y] __________________________________________________________________________
/home/ben/src/forks/typeguard/tests/test_checkers.py:494: in test_typed_dict
    pytest.raises(TypeCheckError, check_type, value, DummyDict).match(error_re)
/home/ben/src/forks/typeguard/src/typeguard/_functions.py:106: in check_type
    check_type_internal(value, expected_type, memo)
/home/ben/src/forks/typeguard/src/typeguard/_checkers.py:783: in check_type_internal
    if not isinstance(value, origin_type):
/home/ben/src/forks/typeguard/_e/lib64/python3.13/site-packages/typing_extensions.py:951: in __subclasscheck__
    raise TypeError('TypedDict does not support instance and class checks')
E   TypeError: TypedDict does not support instance and class checks
_____________________________________________________________________ TestTypedDict.test_typed_dict[typing_extensions-missing_y_error] ______________________________________________________________________
/home/ben/src/forks/typeguard/tests/test_checkers.py:494: in test_typed_dict
    pytest.raises(TypeCheckError, check_type, value, DummyDict).match(error_re)
/home/ben/src/forks/typeguard/src/typeguard/_functions.py:106: in check_type
    check_type_internal(value, expected_type, memo)
/home/ben/src/forks/typeguard/src/typeguard/_checkers.py:783: in check_type_internal
    if not isinstance(value, origin_type):
/home/ben/src/forks/typeguard/_e/lib64/python3.13/site-packages/typing_extensions.py:951: in __subclasscheck__
    raise TypeError('TypedDict does not support instance and class checks')
E   TypeError: TypedDict does not support instance and class checks
_______________________________________________________________________ TestTypedDict.test_typed_dict[typing_extensions-missing_y_ok] _______________________________________________________________________
/home/ben/src/forks/typeguard/tests/test_checkers.py:496: in test_typed_dict
    check_type(value, DummyDict)
/home/ben/src/forks/typeguard/src/typeguard/_functions.py:106: in check_type
    check_type_internal(value, expected_type, memo)
/home/ben/src/forks/typeguard/src/typeguard/_checkers.py:783: in check_type_internal
    if not isinstance(value, origin_type):
/home/ben/src/forks/typeguard/_e/lib64/python3.13/site-packages/typing_extensions.py:951: in __subclasscheck__
    raise TypeError('TypedDict does not support instance and class checks')
E   TypeError: TypedDict does not support instance and class checks
_________________________________________________________________________ TestTypedDict.test_typed_dict[typing_extensions-wrong_x] __________________________________________________________________________
/home/ben/src/forks/typeguard/tests/test_checkers.py:494: in test_typed_dict
    pytest.raises(TypeCheckError, check_type, value, DummyDict).match(error_re)
/home/ben/src/forks/typeguard/src/typeguard/_functions.py:106: in check_type
    check_type_internal(value, expected_type, memo)
/home/ben/src/forks/typeguard/src/typeguard/_checkers.py:783: in check_type_internal
    if not isinstance(value, origin_type):
/home/ben/src/forks/typeguard/_e/lib64/python3.13/site-packages/typing_extensions.py:951: in __subclasscheck__
    raise TypeError('TypedDict does not support instance and class checks')
E   TypeError: TypedDict does not support instance and class checks
_______________________________________________________________________ TestTypedDict.test_typed_dict[typing_extensions-unknown_key] ________________________________________________________________________
/home/ben/src/forks/typeguard/tests/test_checkers.py:494: in test_typed_dict
    pytest.raises(TypeCheckError, check_type, value, DummyDict).match(error_re)
/home/ben/src/forks/typeguard/src/typeguard/_functions.py:106: in check_type
    check_type_internal(value, expected_type, memo)
/home/ben/src/forks/typeguard/src/typeguard/_checkers.py:783: in check_type_internal
    if not isinstance(value, origin_type):
/home/ben/src/forks/typeguard/_e/lib64/python3.13/site-packages/typing_extensions.py:951: in __subclasscheck__
    raise TypeError('TypedDict does not support instance and class checks')
E   TypeError: TypedDict does not support instance and class checks
_________________________________________________________________________ TestTypedDict.test_typed_dict[typing_extensions-not_dict] _________________________________________________________________________
/home/ben/src/forks/typeguard/tests/test_checkers.py:494: in test_typed_dict
    pytest.raises(TypeCheckError, check_type, value, DummyDict).match(error_re)
/home/ben/src/forks/typeguard/src/typeguard/_functions.py:106: in check_type
    check_type_internal(value, expected_type, memo)
/home/ben/src/forks/typeguard/src/typeguard/_checkers.py:783: in check_type_internal
    if not isinstance(value, origin_type):
/home/ben/src/forks/typeguard/_e/lib64/python3.13/site-packages/typing_extensions.py:951: in __subclasscheck__
    raise TypeError('TypedDict does not support instance and class checks')
E   TypeError: TypedDict does not support instance and class checks
______________________________________________________________________ TestTypedDict.test_inconsistent_keys_invalid[typing_extensions] ______________________________________________________________________
/home/ben/src/forks/typeguard/tests/test_checkers.py:502: in test_inconsistent_keys_invalid
    pytest.raises(
/home/ben/src/forks/typeguard/src/typeguard/_functions.py:106: in check_type
    check_type_internal(value, expected_type, memo)
/home/ben/src/forks/typeguard/src/typeguard/_checkers.py:783: in check_type_internal
    if not isinstance(value, origin_type):
/home/ben/src/forks/typeguard/_e/lib64/python3.13/site-packages/typing_extensions.py:951: in __subclasscheck__
    raise TypeError('TypedDict does not support instance and class checks')
E   TypeError: TypedDict does not support instance and class checks
__________________________________________________________________________ TestTypedDict.test_notrequired_pass[typing_extensions] ___________________________________________________________________________
/home/ben/src/forks/typeguard/tests/test_checkers.py:516: in test_notrequired_pass
    check_type({"x": 8}, DummyDict)
/home/ben/src/forks/typeguard/src/typeguard/_functions.py:106: in check_type
    check_type_internal(value, expected_type, memo)
/home/ben/src/forks/typeguard/src/typeguard/_checkers.py:783: in check_type_internal
    if not isinstance(value, origin_type):
/home/ben/src/forks/typeguard/_e/lib64/python3.13/site-packages/typing_extensions.py:951: in __subclasscheck__
    raise TypeError('TypedDict does not support instance and class checks')
E   TypeError: TypedDict does not support instance and class checks
__________________________________________________________________________ TestTypedDict.test_notrequired_fail[typing_extensions] ___________________________________________________________________________
/home/ben/src/forks/typeguard/tests/test_checkers.py:531: in test_notrequired_fail
    check_type({"x": 1, "y": "foo"}, DummyDict)
/home/ben/src/forks/typeguard/src/typeguard/_functions.py:106: in check_type
    check_type_internal(value, expected_type, memo)
/home/ben/src/forks/typeguard/src/typeguard/_checkers.py:783: in check_type_internal
    if not isinstance(value, origin_type):
/home/ben/src/forks/typeguard/_e/lib64/python3.13/site-packages/typing_extensions.py:951: in __subclasscheck__
    raise TypeError('TypedDict does not support instance and class checks')
E   TypeError: TypedDict does not support instance and class checks

How can we reproduce the bug?

$ gh repo clone agronholm/typeguard
$ cd typeguard
$ git checkout 4.2.1
$ python3.13 --version
Python 3.13.0a5
$ . _e/bin/activate
$ python3.13 -m venv _e
(_e) $ pip install -e .[test]
(_e) $ python -m pytest
@musicinmybrain
Copy link
Author

This is very similar to #443, but it seems to be specific to Python 3.13, and occurs in a release that already contains d481a51.

@agronholm
Copy link
Owner

Yep, I'm aware of this, and I think this is caused by typing_extensions not yet supporting Python 3.13. Typeguard relies on typing_extensions.is_typeddict() to recognize typed dicts from both that library and the standard library.

@musicinmybrain
Copy link
Author

Thanks for the response. If the problem is in typing_extensions, I wonder if they know about it. Release 4.11.0 advertises Python 3.13.0a5 compatibility, and Python 3.13 appears to be in their test matrix.

@agronholm
Copy link
Owner

I need to thoroughly check this before filing any issue with them.

@musicinmybrain
Copy link
Author

Ok! No big hurry – I’ll track this issue. Thanks for looking into it, and please let me know if there’s anything I can do.

@agronholm
Copy link
Owner

It looks like they're no longer using typing.TypedDict as typing_extensions.TypedDict, so I need to change the dependencies again.

@agronholm
Copy link
Owner

Yeah, this is definitely fixable on my side, but I need a good night's rest to wrap my head around the solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants