mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-17 11:17:17 +03:00
Fixed regression where "__class__" symbol (defined in PEP 3135) was not added implicitly to a function scope.
This commit is contained in:
parent
41424cc28e
commit
14931faf4e
@ -417,6 +417,12 @@ export class Binder extends ParseTreeWalker {
|
||||
this._createNewScope(ScopeType.Function, functionOrModuleScope, () => {
|
||||
AnalyzerNodeInfo.setScope(node, this._currentScope!);
|
||||
|
||||
const enclosingClass = ParseTreeUtils.getEnclosingClass(node);
|
||||
if (enclosingClass) {
|
||||
// Add the implicit "__class__" symbol described in PEP 3135.
|
||||
this._addBuiltInSymbolToCurrentScope('__class__', node, 'class');
|
||||
}
|
||||
|
||||
this._deferBinding(() => {
|
||||
// Create a start node for the function.
|
||||
this._currentFlowNode = this._createStartFlowNode();
|
||||
|
@ -9,7 +9,8 @@ class Bar(Foo):
|
||||
pass
|
||||
|
||||
class Bar2(Foo, metaclass=type):
|
||||
pass
|
||||
def my_method(self):
|
||||
print(__class__)
|
||||
|
||||
# This should generate an error because only one metaclass is supported.
|
||||
class Bar3(Foo, metaclass=type, metaclass=type):
|
||||
|
Loading…
Reference in New Issue
Block a user