ruff
102c2eec - [red-knot] Implicit instance attributes (#15811)

Commit
151 days ago
[red-knot] Implicit instance attributes (#15811) ## Summary Add support for implicitly-defined instance attributes, i.e. support type inference for cases like this: ```py class C: def __init__(self) -> None: self.x: int = 1 self.y = None reveal_type(C().x) # int reveal_type(C().y) # Unknown | None ``` ## Benchmarks Codspeed reports no change in a cold-cache benchmark, and a -1% regression in the incremental benchmark. On `black`'s `src` folder, I don't see a statistically significant difference between the branches: | Command | Mean [ms] | Min [ms] | Max [ms] | Relative | |:---|---:|---:|---:|---:| | `./red_knot_main check --project /home/shark/black/src` | 133.7 ± 9.5 | 126.7 | 164.7 | 1.01 ± 0.08 | | `./red_knot_feature check --project /home/shark/black/src` | 132.2 ± 5.1 | 118.1 | 140.9 | 1.00 | ## Test Plan Updated and new Markdown tests
Author
Parents
  • crates/red_knot_python_semantic
    • resources/mdtest
      • File
        attributes.md
    • src
      • File
        semantic_index.rs
      • semantic_index
        • File
          attribute_assignment.rs
        • File
          builder.rs
        • File
          expression.rs
        • File
          symbol.rs
      • File
        types.rs
      • types
        • File
          infer.rs