KEMBAR78
[stubtest] Allow runtime-existing aliases of types marked as `@type_check_only` by brianschubert · Pull Request #19568 · python/mypy · GitHub
Skip to content

Conversation

brianschubert
Copy link
Member

In typeshed, there's a few cases of stubs like this:

class _DoesNotExist: ...  # does not exist at runtime

if sys.version_info >= (3, X):
    Exists = _DoesNotExist

Ideally, it would be nice to mark _DoesNotExit as @type_check_only to make it clear that this type isn't available at runtime. However, this currently can't be done, because doing so will make stubtest think that Exists is also @type_check_only, which sets off alarm bells due to Exists being available at runtime.

This PR makes it so stubtest doesn't consider @type_check_only-status when checking type alias targets, making it possible to mark types like the above as @type_check_only.

@ilevkivskyi ilevkivskyi merged commit e8147f2 into python:master Aug 2, 2025
13 checks passed
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

Successfully merging this pull request may close these issues.

2 participants