ruff/crates/ty_python_semantic/src
Shunsuke Shibayama 08a561fc05
[ty] more precise lazy scope place lookup (#19932)
## Summary

This is a follow-up to https://github.com/astral-sh/ruff/pull/19321.

Now lazy snapshots are updated to take into account new bindings on
every symbol reassignment.

```python
def outer(x: A | None):
    if x is None:
        x = A()

    reveal_type(x)  # revealed: A

    def inner() -> None:
        # lazy snapshot: {x: A}
        reveal_type(x)  # revealed: A
    inner()

def outer() -> None:
    x = None

    x = 1

    def inner() -> None:
        # lazy snapshot: {x: Literal[1]} -> {x: Literal[1, 2]}
        reveal_type(x)  # revealed: Literal[1, 2]
    inner()

    x = 2
```

Closes astral-sh/ty#559.

## Test Plan

Some TODOs in `public_types.md` now work properly.

---------

Co-authored-by: Carl Meyer <carl@astral.sh>
2025-09-08 21:08:35 +00:00
..
module_resolver [ty] Add naive implementation of completions for unimported symbols 2025-09-03 09:57:26 -04:00
semantic_index [ty] more precise lazy scope place lookup (#19932) 2025-09-08 21:08:35 +00:00
types [ty] more precise lazy scope place lookup (#19932) 2025-09-08 21:08:35 +00:00
util [ty] Avoid overcounting shared memory usage (#19773) 2025-08-06 15:32:02 -04:00
ast_node_ref.rs [ty] Implement the legacy PEP-484 convention for indicating positional-only parameters (#20248) 2025-09-05 17:56:06 +01:00
db.rs [ty] Track open files in the server (#19264) 2025-07-18 19:33:35 +05:30
dunder_all.rs [ty] Avoid overcounting shared memory usage (#19773) 2025-08-06 15:32:02 -04:00
lib.rs [ty] Add naive implementation of completions for unimported symbols 2025-09-03 09:57:26 -04:00
lint.rs [ty] Add environment variable to dump Salsa memory usage stats (#18928) 2025-06-26 21:27:51 +00:00
list.rs Update Rust toolchain to 1.89 (#19807) 2025-08-07 18:21:50 +02:00
module_name.rs [ty] Split out another constructor for ModuleName 2025-08-20 10:27:54 -04:00
node_key.rs [ty] Implement the legacy PEP-484 convention for indicating positional-only parameters (#20248) 2025-09-05 17:56:06 +01:00
place.rs [ty] Add backreferences to TypedDict items in diagnostics (#20262) 2025-09-05 12:38:37 +02:00
program.rs [ty] Track heap usage of salsa structs (#19790) 2025-08-12 13:28:44 +02:00
pull_types.rs Update Rust toolchain to 1.88 and MSRV to 1.86 (#19011) 2025-06-28 20:24:00 +02:00
python_platform.rs [ty] Track heap usage of salsa structs (#19790) 2025-08-12 13:28:44 +02:00
rank.rs [ty] Garbage-collect reachability constraints (#19414) 2025-07-21 14:16:27 -04:00
semantic_index.rs [ty] Implement the legacy PEP-484 convention for indicating positional-only parameters (#20248) 2025-09-05 17:56:06 +01:00
semantic_model.rs [ty] Add naive implementation of completions for unimported symbols 2025-09-03 09:57:26 -04:00
site_packages.rs [ty] Disallow std::env and io methods in most ty crates (#20046) 2025-08-22 11:13:47 -07:00
suppression.rs Update Rust toolchain to 1.89 (#19807) 2025-08-07 18:21:50 +02:00
types.rs [ty] Add support for generic PEP695 type aliases (#20219) 2025-09-08 13:26:21 -07:00
unpack.rs [ty] Track heap usage of salsa structs (#19790) 2025-08-12 13:28:44 +02:00