@@ -13,11 +13,6 @@ found in the global scope. The `builtins.pyi` file, that will be used to resolve
13
13
builtins scope, contains multiple symbols from other modules (e.g., ` typing ` ) but those are not
14
14
re-exported.
15
15
16
- As per [ PEP 484] ( https://peps.python.org/pep-0484/#stub-files ) :
17
-
18
- > Modules and variables imported into the stub are not considered exported from the stub unless the
19
- > import uses the ` import ... as ... ` form or the equivalent ` from ... import ... as ... ` form.
20
-
21
16
``` py
22
17
# These symbols are being imported in `builtins.pyi` but shouldn't be considered as being
23
18
# available in the builtins scope.
@@ -31,8 +26,8 @@ reveal_type(sys) # revealed: Unknown
31
26
32
27
## Builtins import
33
28
34
- Similarly, trying to import the symbols from the builtins module which aren't re-exported
35
- should also raise an error.
29
+ Similarly, trying to import the symbols from the builtins module which aren't re-exported should
30
+ also raise an error.
36
31
37
32
``` py
38
33
# error: "Module `builtins` has no member `Literal`"
@@ -51,8 +46,8 @@ reveal_type(Iterable) # revealed: Unknown
51
46
52
47
## Explicitly re-exported symbols in stub files
53
48
54
- When a symbol is re-exported, imporing it should not raise an error.
55
- This tests both ` import ... ` and ` from ... import ... ` forms.
49
+ When a symbol is re-exported, imporing it should not raise an error. This tests both ` import ... `
50
+ and ` from ... import ... ` forms.
56
51
57
52
Note: Submodule imports in ` import ... ` form doesn't work because it's a syntax error. For example,
58
53
in ` import os.path as os.path ` the ` os.path ` is not a valid identifier.
@@ -216,15 +211,15 @@ from a import Foo
216
211
` a.pyi ` :
217
212
218
213
``` pyi
219
- from b import AnyFoo as Foo
214
+ from b import Foo
220
215
221
216
__all__ = [' Foo' ]
222
217
```
223
218
224
219
` b.pyi ` :
225
220
226
221
``` pyi
227
- class AnyFoo : ...
222
+ class Foo : ...
228
223
```
229
224
230
225
## Runtime files
@@ -334,8 +329,8 @@ class Foo: ...
334
329
335
330
## Re-exports in ` __init__.pyi `
336
331
337
- Similarly, for an ` __init__.pyi ` (stub) file, importing a non-exported name should raise an error but the
338
- inference would be ` Unknown ` .
332
+ Similarly, for an ` __init__.pyi ` (stub) file, importing a non-exported name should raise an error
333
+ but the inference would be ` Unknown ` .
339
334
340
335
``` py
341
336
# error: 15 "Module `a` has no member `Foo`"
0 commit comments