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

Fixed the ability to import markupsafe with runtime type checker #456

Closed
wants to merge 1 commit into from

Conversation

minmax
Copy link

@minmax minmax commented Jul 5, 2024

Hello, I came here from beartype/beartype#404 and I think I need to explain a little the reason for my appearance here.

I want to use full type checking at runtime when running tests.
It works as follows - import hooks are installed and each imported module will be checked for type safety at the moment when Python goes line by line through the new files.

Which leads to a certain peculiarity: information about types (type hints) is required not only in conjunction with TYPE_CHECKING, but also at runtime, which is why I needed to create this pull request in order to correct types at runtime.

@davidism
Copy link
Member

davidism commented Jul 6, 2024

Sorry, Pallets generally avoids adding required/runtime dependencies. Once Protocol is available in our minimum supported version of Python, we will no longer need the TYPE_CHECKING block for it.

I'm not a type checking expert, so I couldn't really follow the linked discussion. It sounds like the feature you're trying to use is not expected to work in all cases yet and is still under development. Perhaps it could do some amount of static analysis with TYPE_CHECKING=True in order to extract these sorts of definitions. Or perhaps it could issue a warning and fall back to less accurate type checks to match what a given library exposes at runtime, rather than failing.

@davidism davidism closed this Jul 6, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants