Files
Mikhail Golubevandintellij-monorepo-bot 820da7c49c PY-77940 Allow resolving underscored names in .pyi stubs
This reverts the changes made in eb733982acf0992fbae822d0feb582fb07ad010f
for PY-40233.

The original problem was PyShadowingBuiltinsInspection erroneously reporting
redefining private names declared in builtins.pyi, such as _T, however,
resolving underscored names from all .pyi stubs was prohibited to fix that.

These are considered "stub-only objects" according to the typing spec
(https://typing.readthedocs.io/en/latest/guides/writing_stubs.html#stub-only-objects),
but it doesn't prohibit reusing them in other stubs and in .py files under
an `if typing.TYPE_CHECKING:` guard.
Besides, both Mypy and Pyright resolve such names imported from .pyi stubs without warnings,
so it doesn't make sense to enforce additional visibility restrictions from our side.

Also, I enabled completing such names in other .pyi stubs (but not in .py files).
Previously, in PY-38172 their completion was disabled everywhere.

GitOrigin-RevId: 8340d4dcaf732d18d481bbee824ffdddd2719d3d
2024-12-18 16:55:26 +00:00

4 lines
77 B
Python

import typing
if typing.TYPE_CHECKING:
from _common import _Place<caret>