|
18 | 18 | using System.Linq;
|
19 | 19 | using Microsoft.Python.Analysis.Analyzer.Evaluation;
|
20 | 20 | using Microsoft.Python.Analysis.Diagnostics;
|
| 21 | +using Microsoft.Python.Analysis.Modules; |
| 22 | +using Microsoft.Python.Analysis.Specializations.Typing; |
21 | 23 | using Microsoft.Python.Analysis.Types;
|
22 | 24 | using Microsoft.Python.Analysis.Values;
|
23 | 25 | using Microsoft.Python.Core;
|
@@ -117,17 +119,26 @@ private IEnumerable<IPythonType> ProcessBases(Scope outerScope) {
|
117 | 119 | var expr = a.Expression;
|
118 | 120 | var m = Eval.GetValueFromExpression(expr);
|
119 | 121 |
|
120 |
| - switch (m?.MemberType) { |
121 |
| - case PythonMemberType.Method: |
122 |
| - case PythonMemberType.Function: |
123 |
| - case PythonMemberType.Property: |
124 |
| - case PythonMemberType.Instance: |
125 |
| - case PythonMemberType.Variable when m is IPythonConstant: |
126 |
| - // all invalid types to inherit from |
127 |
| - ReportInvalidBase(a.ToCodeString(Eval.Ast, CodeFormattingOptions.Traditional)); |
| 122 | + switch (m) { |
| 123 | + // Allow any members from typing module |
| 124 | + // TODO handle typing module specialization better: https://github.com/microsoft/python-language-server/issues/1367 |
| 125 | + case ILocatedMember l when l.DeclaringModule is TypingModule: |
| 126 | + TryAddBase(bases, a); |
128 | 127 | break;
|
129 | 128 | default:
|
130 |
| - TryAddBase(bases, a); |
| 129 | + switch (m?.MemberType) { |
| 130 | + case PythonMemberType.Method: |
| 131 | + case PythonMemberType.Function: |
| 132 | + case PythonMemberType.Property: |
| 133 | + case PythonMemberType.Instance: |
| 134 | + case PythonMemberType.Variable when m is IPythonConstant: |
| 135 | + // all invalid types to inherit from |
| 136 | + ReportInvalidBase(a.ToCodeString(Eval.Ast, CodeFormattingOptions.Traditional)); |
| 137 | + break; |
| 138 | + default: |
| 139 | + TryAddBase(bases, a); |
| 140 | + break; |
| 141 | + } |
131 | 142 | break;
|
132 | 143 | }
|
133 | 144 | }
|
|
0 commit comments