Underscored objects in stubs are not public and should never be listed

This commit is contained in:
Dave Halter
2018-11-03 14:36:46 +01:00
parent 1eb8658922
commit 26329de5a5
2 changed files with 8 additions and 0 deletions

View File

@@ -276,6 +276,9 @@ class StubOnlyFilter(ParserTreeFilter):
if definition.type in ('import_from', 'import_name'):
if name.parent.type not in ('import_as_name', 'dotted_as_name'):
return False
n = name.value
if n.startswith('_') and not (n.startswith('__') and n.endswith('__')):
return False
return True

View File

@@ -71,6 +71,11 @@ if os.path.isfile():
#? ['abspath']
fails = os.path.abspath
# The type vars and other underscored things from typeshed should not be
# findable.
#?
os._T
with open('foo') as f:
for line in f.readlines():