Closed minmax closed 4 months ago
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.
Hello, I came here from https://github.com/beartype/beartype/issues/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.