From b5017de462d43e055db7017984c40b6305f7b5be Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Tue, 23 Feb 2021 01:02:15 -0700 Subject: [PATCH] =?UTF-8?q?Updated=20typed=20library=20documentation=20to?= =?UTF-8?q?=20explicitly=20mention=20import=20statements=20of=20the=20form?= =?UTF-8?q?=20=E2=80=9Cfrom=20.=20import=20A=E2=80=9D=C2=A0and=20=E2=80=9C?= =?UTF-8?q?from=20.A=20import=20X=E2=80=9D.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/typed-libraries.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/typed-libraries.md b/docs/typed-libraries.md index 41789e98c..99daaee70 100644 --- a/docs/typed-libraries.md +++ b/docs/typed-libraries.md @@ -32,7 +32,7 @@ If a “py.typed” module is present, a type checker will treat all modules wit Each module exposes a set of symbols. Some of these symbols are considered “private” — implementation details that are not part of the library’s interface. Type checkers like pyright use the following rules to determine which symbols are visible outside of the package. * Symbols whose names begin with an underscore (but are not dunder names) are considered private. -* Imported symbols are considered private by default. If they use the “import A as A” (a redundant module alias), “from A import X as X” (a redundant symbol alias) or “from A import *” forms, they are not private (unless their names begin with an underscore). +* Imported symbols are considered private by default. If they use the “import A as A” (a redundant module alias), “from X import A as A” (a redundant symbol alias), “from . import A”, or “from .A import X” forms, symbol “A” is not private unless the name begins with an underscore. Likewise, if a wildcard import (of the form “from X import *”) is used, all symbols referenced by the wildcard are not private. * A module can expose an `__all__` symbol at the module level that provides a list of names that are considered part of the interface. This overrides all other rules above, allowing imported symbols or symbols whose names begin with an underscore to be included in the interface. * Local variables within a function (including nested functions) are always considered private.