From 26329de5a56203e65c4288c3e5b1d92d495fb7aa Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Sat, 3 Nov 2018 14:36:46 +0100 Subject: [PATCH] Underscored objects in stubs are not public and should never be listed --- jedi/plugins/typeshed.py | 3 +++ test/completion/stdlib.py | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/jedi/plugins/typeshed.py b/jedi/plugins/typeshed.py index f496ee93..c7a9fa6e 100644 --- a/jedi/plugins/typeshed.py +++ b/jedi/plugins/typeshed.py @@ -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 diff --git a/test/completion/stdlib.py b/test/completion/stdlib.py index 68987bf0..140f3dae 100644 --- a/test/completion/stdlib.py +++ b/test/completion/stdlib.py @@ -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():