mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
[red-knot] Add regression tests for narrowing constraints cycles (#17408)
Some checks are pending
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (linux, release) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / mkdocs (push) Waiting to run
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Waiting to run
CI / cargo build (msrv) (push) Blocked by required conditions
CI / cargo fuzz build (push) Blocked by required conditions
CI / fuzz parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / check playground (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
[Knot Playground] Release / publish (push) Waiting to run
Some checks are pending
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (linux, release) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / mkdocs (push) Waiting to run
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Waiting to run
CI / cargo build (msrv) (push) Blocked by required conditions
CI / cargo fuzz build (push) Blocked by required conditions
CI / fuzz parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / check playground (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
[Knot Playground] Release / publish (push) Waiting to run
## Summary
closes #17215
This PR adds regression tests for the following cycled queries:
- all_narrowing_constraints_for_expression
- all_negative_narrowing_constraints_for_expression
The following test files are included:
-
`red_knot_project/resources/test/corpus/cycle_narrowing_constraints.py`
-
`red_knot_project/resources/test/corpus/cycle_negative_narrowing_constraints.py`
These test names don't follow the existing naming convention based on
Cinder.
However, I’ve chosen these names to clearly reflect the regression
cases.
Let me know if you’d prefer to align more closely with the existing
Cinder-based style.
## Test Plan
```sh
git checkout 1a6a10b30
cargo test --package red_knot_project -- corpus
```
This commit is contained in:
parent
312a487ea7
commit
942cb9e3ad
2 changed files with 37 additions and 0 deletions
|
@ -0,0 +1,15 @@
|
|||
# Regression test for https://github.com/astral-sh/ruff/issues/17215
|
||||
# panicked in commit 1a6a10b30
|
||||
# error message:
|
||||
# dependency graph cycle querying all_narrowing_constraints_for_expression(Id(8591))
|
||||
|
||||
def f(a: A, b: B, c: C):
|
||||
unknown_a: UA = make_unknown()
|
||||
unknown_b: UB = make_unknown()
|
||||
unknown_c: UC = make_unknown()
|
||||
unknown_d: UD = make_unknown()
|
||||
|
||||
if unknown_a and unknown_b:
|
||||
if unknown_c:
|
||||
if unknown_d:
|
||||
return a, b, c
|
|
@ -0,0 +1,22 @@
|
|||
# Regression test for https://github.com/astral-sh/ruff/issues/17215
|
||||
# panicked in commit 1a6a10b30
|
||||
# error message:
|
||||
# dependency graph cycle querying all_negative_narrowing_constraints_for_expression(Id(859f))
|
||||
|
||||
def f(f1: bool, f2: bool, f3: bool, f4: bool):
|
||||
o1: UnknownClass = make_o()
|
||||
o2: UnknownClass = make_o()
|
||||
o3: UnknownClass = make_o()
|
||||
o4: UnknownClass = make_o()
|
||||
|
||||
if f1 and f2 and f3 and f4:
|
||||
if o1 == o2:
|
||||
return None
|
||||
if o2 == o3:
|
||||
return None
|
||||
if o3 == o4:
|
||||
return None
|
||||
if o4 == o1:
|
||||
return None
|
||||
|
||||
return o1, o2, o3, o4
|
Loading…
Add table
Add a link
Reference in a new issue