Skip to content
This repository has been archived by the owner on Apr 14, 2022. It is now read-only.

Unfilter __all__ #708

Merged
merged 1 commit into from
Mar 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions src/Analysis/Ast/Impl/Modules/PythonModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,20 +149,11 @@ public virtual string Documentation {
#region IMemberContainer
public virtual IMember GetMember(string name) => Analysis.GlobalScope.Variables[name]?.Value;
public virtual IEnumerable<string> GetMemberNames() {
// Try __all__ since it contains exported members
var all = Analysis.GlobalScope.Variables["__all__"];
if (all?.Value is IPythonCollection collection) {
return collection.Contents
.OfType<IPythonConstant>()
.Select(c => c.GetString())
.Where(s => !string.IsNullOrEmpty(s));
}
// TODO: Filter __all__. See: https://github.com/Microsoft/python-language-server/issues/620

// __all__ is not declared. Try filtering by origin:
// drop imported modules and generics.
// drop imported modules and typing.
return Analysis.GlobalScope.Variables
.Where(v => v.Value?.MemberType != PythonMemberType.Generic
&& !(v.Value?.GetPythonType() is PythonModule)
.Where(v => !(v.Value?.GetPythonType() is PythonModule)
&& !(v.Value?.GetPythonType().DeclaringModule is TypingModule && !(this is TypingModule)))
.Select(v => v.Name);
}
Expand Down