mirror of
https://github.com/microsoft/pyright.git
synced 2024-08-15 19:00:33 +03:00
Changed the behavior of double underscored symbols that are part of a module's namespace when that module is not a stub or in a "py.typed" package. Such symbols are no longer ignored, although they are considered private. This addresses #8131. (#8132)
This commit is contained in:
parent
5d77369056
commit
32f44d921a
@ -3455,8 +3455,12 @@ export class Binder extends ParseTreeWalker {
|
||||
if (this._currentScope.type === ScopeType.Module || this._currentScope.type === ScopeType.Builtin) {
|
||||
if (isPrivateOrProtectedName(name)) {
|
||||
if (isPrivateName(name)) {
|
||||
// Private names are obscured, so they are always externally hidden.
|
||||
symbol.setIsExternallyHidden();
|
||||
// Private names within classes are mangled, so they are always externally hidden.
|
||||
if (scope.type === ScopeType.Class) {
|
||||
symbol.setIsExternallyHidden();
|
||||
} else {
|
||||
this._potentialPrivateSymbols.set(name, symbol);
|
||||
}
|
||||
} else if (this._fileInfo.isStubFile || this._fileInfo.isInPyTypedPackage) {
|
||||
if (this._currentScope.type === ScopeType.Builtin) {
|
||||
// Don't include private-named symbols in the builtin scope.
|
||||
|
@ -7,9 +7,9 @@
|
||||
//// [|__foo/*marker*/|]()
|
||||
|
||||
// @filename: test2.py
|
||||
//// from test1 import __foo
|
||||
//// from test1 import [|__foo|]
|
||||
////
|
||||
//// __foo()
|
||||
//// [|__foo|]()
|
||||
|
||||
helper.verifyRename({
|
||||
marker: {
|
||||
|
@ -9,7 +9,7 @@
|
||||
// @filename: test2.py
|
||||
//// from test1 import __foo
|
||||
////
|
||||
//// __foo(param=1)
|
||||
//// __foo([|param|]=1)
|
||||
|
||||
helper.verifyRename({
|
||||
marker: {
|
||||
|
Loading…
Reference in New Issue
Block a user