Skip to content

Mark stub-only private symbols as @type_check_only in third-party stubs #14545

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

This fixes the third-party stubtest errors from python/mypy#19574.

Mostly obvious cases like stub-only Protocols or TypedDicts. I've added inline comments to some of the less obvious cases that took some investigation.

Comment on lines -12 to -15
class _DatetimeWithFold(datetime):
@property
def fold(self): ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines -6 to 7
@runtime_checkable
@type_check_only
class _Readable(Protocol):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likely a typo for @type_check_only - _Readable didn't exist at the time when it was added to the stubs

Comment on lines -62 to -70
class _FieldMaskTree:
def __init__(self, field_mask: Incomplete | None = ...) -> None: ...
def MergeFromFieldMask(self, field_mask: tAny) -> None: ...
def AddPath(self, path: tAny): ...
def ToFieldMask(self, field_mask: tAny) -> None: ...
def IntersectPath(self, path: tAny, intersection: tAny): ...
def AddLeafNodes(self, prefix: tAny, node: tAny) -> None: ...
def MergeMessage(self, source: tAny, destination: tAny, replace_message: tAny, replace_repeated: tAny) -> None: ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines -49 to -50
class _BetaConfiguration(SetuptoolsWarning): ...
class _InvalidFile(SetuptoolsWarning): ...
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -77,4 +77,3 @@ class _NamespaceInstaller(namespaces.Installer):

class InformationOnly(SetuptoolsWarning): ...
class LinksNotSupported(errors.FileError): ...
class _DebuggingTips(SetuptoolsWarning): ...
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

github-actions bot commented Aug 7, 2025

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the final push to redeem @type_check_only.

@srittau srittau merged commit 81c8fcb into python:main Aug 8, 2025
48 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