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

[Feature request] Support for TypedDict #319

Open
tvdboom opened this issue Jan 29, 2024 · 2 comments
Open

[Feature request] Support for TypedDict #319

tvdboom opened this issue Jan 29, 2024 · 2 comments

Comments

@tvdboom
Copy link

tvdboom commented Jan 29, 2024

It would be nice if beartype could detect TypedDict annotations. Currently (v0.17.0), all dicts pass a TypedDict test. Example:

from beartype.door import is_bearable
from typing import TypedDict

class ABC(TypedDict):
    a: int

print(is_bearable({}, ABC))  # -> True, should be False
print(is_bearable({"b": 2}, ABC))  # -> True, should be False
print(is_bearable({"a": "a"}, ABC))  # -> True, should be False
@tvdboom tvdboom changed the title [Feature request] Support for TypeDict [Feature request] Support for TypedDict Jan 29, 2024
@leycec
Copy link
Member

leycec commented Jan 30, 2024

Absolutely right. As always, you force us to become better people.

2024 is the year that @beartype finally goes hard on deep type-checking. So, this is happening. Still, we should (probably) deeply type-check standard dictionary type hints like dict[str, int] and standard mapping type hints like typing.MutableMapping[Any, bytes] first. That probably puts deep type-checking of typing.TypedDict more towards the end than the beginning of 2024. I'm so sorry for your codebase. 😭

@tvdboom
Copy link
Author

tvdboom commented Jan 30, 2024

Sounds good! Thanks for all the work

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

No branches or pull requests

2 participants