Skip to content

[stubtest] Allow runtime-existing aliases of types marked as @type_check_only #19568

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

Merged

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