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:
Eric Traut 2024-06-12 14:01:56 -07:00 committed by GitHub
parent 5d77369056
commit 32f44d921a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 5 deletions

View File

@ -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.

View File

@ -7,9 +7,9 @@
//// [|__foo/*marker*/|]()
// @filename: test2.py
//// from test1 import __foo
//// from test1 import [|__foo|]
////
//// __foo()
//// [|__foo|]()
helper.verifyRename({
marker: {

View File

@ -9,7 +9,7 @@
// @filename: test2.py
//// from test1 import __foo
////
//// __foo(param=1)
//// __foo([|param|]=1)
helper.verifyRename({
marker: {