Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
78f2f08
[ty] Add support for `__all__`
dhruvmanila May 4, 2025
3554ece
Fix mdtests
dhruvmanila May 5, 2025
eb06444
Add cycle handling
dhruvmanila May 5, 2025
34de11d
Consider `__all__` not present if there are invalid elements
dhruvmanila May 5, 2025
090edd7
Check `__all__` for re-export convention
dhruvmanila May 5, 2025
9f7e012
Update mdtest
dhruvmanila May 5, 2025
f9b40ba
Simplify imported symbol fn
dhruvmanila May 6, 2025
23c66d9
revert a few things
dhruvmanila May 6, 2025
4c1f977
Avoid dunder all lookup for named imports in non-stub file
dhruvmanila May 6, 2025
6efa496
Add `ty_extensions.dunder_all_names`
dhruvmanila May 6, 2025
9e0c750
Avoid lazy evaluation when `__all__` is imported
dhruvmanila May 6, 2025
5d153bb
Return `None` if `__all__` is not defined
dhruvmanila May 6, 2025
8655d8b
Remove invalid error in mdtest
dhruvmanila May 6, 2025
1d334aa
Add more docs
dhruvmanila May 6, 2025
18b7a78
Initial `__all__` tests
dhruvmanila May 6, 2025
1290012
Add semantic test cases
dhruvmanila May 6, 2025
621a92a
Upgrade salsa
dhruvmanila May 6, 2025
ea98e56
Fix rebase on main
dhruvmanila May 6, 2025
7baca5a
Fix tests and snapshots
dhruvmanila May 6, 2025
589c126
Fix snapshots
dhruvmanila May 6, 2025
4b56950
Move `dunder_all_names` in core symbol lookup
dhruvmanila May 6, 2025
3f8d61d
Fix clippy
dhruvmanila May 6, 2025
7c2f72e
Add `is_reexported` helper fn
dhruvmanila May 7, 2025
675e6e5
Update mdtest
dhruvmanila May 7, 2025
7bf2d08
Update docs
dhruvmanila May 7, 2025
3e4eb00
Allow implicitly concatenated strings
dhruvmanila May 7, 2025
48d0eff
Mark unsupported idioms as invalid
dhruvmanila May 7, 2025
9054654
Add tests for annotated assignment
dhruvmanila May 7, 2025
298f72a
Revert "Upgrade salsa"
dhruvmanila May 7, 2025
603af40
Ignore `__all__` if `submodule.__all__` is invalid
dhruvmanila May 7, 2025
7d5d3ab
Mark invalid for resolving `__all__` from import from
dhruvmanila May 7, 2025
820ac30
Replace "submodule" to "module"
dhruvmanila May 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ reveal_type(SetSubclass.__mro__)

class FrozenSetSubclass(typing.FrozenSet): ...

# TODO: should have `Generic`, should not have `Unknown`
# revealed: tuple[<class 'FrozenSetSubclass'>, <class 'frozenset'>, Unknown, <class 'object'>]
# TODO: generic protocols
# revealed: tuple[<class 'FrozenSetSubclass'>, <class 'frozenset'>, <class 'AbstractSet'>, <class 'Collection'>, <class 'Iterable'>, <class 'Container'>, @Todo(`Protocol[]` subscript), typing.Generic, <class 'object'>]
reveal_type(FrozenSetSubclass.__mro__)

####################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ class AnyFoo: ...
Here, the symbol is re-exported using the `__all__` variable.

```py
# TODO: This should *not* be an error but we don't understand `__all__` yet.
# error: "Module `a` has no member `Foo`"
from a import Foo

reveal_type(Foo) # revealed: <class 'Foo'>
```

`a.pyi`:
Expand All @@ -221,6 +221,44 @@ __all__ = ['Foo']
class Foo: ...
```

## Re-exports with `__all__`

If a symbol is re-exported via redundant alias but is not included in `__all__`, it shouldn't raise
an error when using named import.

`named_import.py`:

```py
from a import Foo

reveal_type(Foo) # revealed: <class 'Foo'>
```

`a.pyi`:

```pyi
from b import Foo as Foo

__all__ = []
```

`b.pyi`:

```pyi
class Foo: ...
```

However, a star import _would_ raise an error.

`star_import.py`:

```py
from a import *

# error: [unresolved-reference] "Name `Foo` used when not defined"
reveal_type(Foo) # revealed: Unknown
```

## Re-exports in `__init__.pyi`

Similarly, for an `__init__.pyi` (stub) file, importing a non-exported name should raise an error
Expand Down
Loading
Loading