Skip to content

[red-knot] Add initial support for * imports #16923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
453bdbc
Add a query that allows us to obtain all global-scope public symbols …
AlexWaygood Mar 21, 2025
728b96c
allow a single node to create multiple definitions, and create a new …
AlexWaygood Mar 21, 2025
4618f3c
Move module-name resolution logic from `infer.rs` to `module_name.rs`
AlexWaygood Mar 22, 2025
29b28e1
hook everything up together
AlexWaygood Mar 22, 2025
ed569b1
rename `index.definition` and improve encapsulation
AlexWaygood Mar 22, 2025
3fec884
clenaup imports
AlexWaygood Mar 22, 2025
705f663
improve behaviour on encountering invalid syntax and add more tests
AlexWaygood Mar 22, 2025
d87cd7c
nit
AlexWaygood Mar 22, 2025
bf7f2c8
fix more edge cases
AlexWaygood Mar 22, 2025
d250477
docs links
AlexWaygood Mar 22, 2025
a6f4152
remove `alias_index` field
AlexWaygood Mar 23, 2025
bcb3ca9
Fix `collections.abc` integration test and add special-casing for `Si…
AlexWaygood Mar 23, 2025
4e6f758
Merge branch 'main' into alex/star-imports-redux
AlexWaygood Mar 23, 2025
0a9b747
fix benchmark and remove outdated TODOs
AlexWaygood Mar 23, 2025
8e8f02d
avoid creating `*` definitions for invalid syntax
AlexWaygood Mar 23, 2025
90263d7
address review
AlexWaygood Mar 24, 2025
94fefef
Various improvements tackling walrus edge cases etc.
AlexWaygood Mar 24, 2025
7af55d1
improve names and comments
AlexWaygood Mar 24, 2025
3bb5d15
always clone in `possibly_add_export` and cache `is_stub`
AlexWaygood Mar 24, 2025
79bd553
Merge branch 'main' into alex/star-imports-redux
AlexWaygood Mar 24, 2025
ca5184f
further improve handling of walruses in lambdas and comprehensions
AlexWaygood Mar 24, 2025
d16682d
Micha review comments
AlexWaygood Mar 24, 2025
1d9a484
add comment explaining indirection
AlexWaygood Mar 24, 2025
210b860
Try to more eagerly maintain invariant that all nodes except `*` impo…
AlexWaygood Mar 24, 2025
54f1bbc
Merge branch 'main' into alex/star-imports-redux
AlexWaygood Mar 24, 2025
c387480
fix deeply nested walruses
AlexWaygood Mar 24, 2025
4b01fbc
Update crates/red_knot_python_semantic/src/semantic_index/builder.rs
AlexWaygood Mar 24, 2025
26e1f20
blacken-docs
AlexWaygood Mar 24, 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 @@ -4,8 +4,10 @@ References:

- <https://typing.readthedocs.io/en/latest/spec/callables.html#callable>

TODO: Use `collections.abc` as importing from `typing` is deprecated but this requires support for
`*` imports. See: <https://docs.python.org/3/library/typing.html#deprecated-aliases>.
Note that `typing.Callable` is deprecated at runtime, in favour of `collections.abc.Callable` (see:
<https://docs.python.org/3/library/typing.html#deprecated-aliases>). However, removal of
`typing.Callable` is not currently planned, and the canonical location of the stub for the symbol in
typeshed is still `typing.pyi`.

## Invalid forms

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ reveal_type(DictSubclass.__mro__)

class SetSubclass(typing.Set): ...

# TODO: should have `Generic`, should not have `Unknown`
# revealed: tuple[Literal[SetSubclass], Literal[set], Unknown, Literal[object]]
# revealed: tuple[Literal[SetSubclass], Literal[set], Literal[MutableSet], Literal[AbstractSet], Literal[Collection], Literal[Iterable], Literal[Container], @Todo(protocol), Literal[object]]
reveal_type(SetSubclass.__mro__)

class FrozenSetSubclass(typing.FrozenSet): ...
Expand Down Expand Up @@ -114,8 +113,7 @@ reveal_type(DefaultDictSubclass.__mro__)

class DequeSubclass(typing.Deque): ...

# TODO: Should be (DequeSubclass, deque, MutableSequence, Sequence, Reversible, Collection, Sized, Iterable, Container, Generic, object)
# revealed: tuple[Literal[DequeSubclass], Literal[deque], Unknown, Literal[object]]
# revealed: tuple[Literal[DequeSubclass], Literal[deque], Literal[MutableSequence], Literal[Sequence], Literal[Reversible], Literal[Collection], Literal[Iterable], Literal[Container], @Todo(protocol), Literal[object]]
reveal_type(DequeSubclass.__mro__)

class OrderedDictSubclass(typing.OrderedDict): ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ reveal_type(C().x) # revealed: str
class C:
def __init__(self) -> None:
# error: [too-many-positional-arguments]
# error: [invalid-argument-type]
self.x: int = len(1, 2, 3)
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,6 @@ reveal_type(len(SecondRequiredArgument())) # revealed: Literal[1]
```py
class NoDunderLen: ...

# TODO: Emit a diagnostic
# error: [invalid-argument-type]
reveal_type(len(NoDunderLen())) # revealed: int
```
Loading
Loading