ruff/crates
Douglas Creager e4a32ba644
Some checks are pending
CI / test scripts (push) Blocked by required conditions
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 (${{ github.repository == 'astral-sh/ruff' && 'depot-windows-2022-16' || 'windows-latest' }}) (push) Blocked by required conditions
CI / cargo test (macos-latest) (push) Blocked by required conditions
CI / pre-commit (push) Waiting to run
CI / cargo test (wasm) (push) Blocked by required conditions
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 / ecosystem (push) Blocked by required conditions
CI / Fuzz for new ty panics (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / ty completion evaluation (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / mkdocs (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 instrumented (ruff) (push) Blocked by required conditions
CI / benchmarks instrumented (ty) (push) Blocked by required conditions
CI / benchmarks walltime (medium|multithreaded) (push) Blocked by required conditions
CI / benchmarks walltime (small|large) (push) Blocked by required conditions
[ty Playground] Release / publish (push) Waiting to run
[ty] Constraint sets compare generic callables correctly (#21392)
Constraint sets can now track subtyping/assignability/etc of generic
callables correctly. For instance:

```py
def identity[T](t: T) -> T:
    return t

constraints = ConstraintSet.always()
static_assert(constraints.implies_subtype_of(TypeOf[identity], Callable[[int], int]))
static_assert(constraints.implies_subtype_of(TypeOf[identity], Callable[[str], str]))
```

A generic callable can be considered an intersection of all of its
possible specializations, and an assignability check with an
intersection as the lhs side succeeds of _any_ of the intersected types
satisfies the check. Put another way, if someone expects to receive any
function with a signature of `(int) -> int`, we can give them
`identity`.

Note that the corresponding check using `is_subtype_of` directly does
not yet work, since #20093 has not yet hooked up the core typing
relationship logic to use constraint sets:

```py
# These currently fail
static_assert(is_subtype_of(TypeOf[identity], Callable[[int], int]))
static_assert(is_subtype_of(TypeOf[identity], Callable[[str], str]))
```

To do this, we add a new _existential quantification_ operation on
constraint sets. This takes in a list of typevars and _removes_ those
typevars from the constraint set. Conceptually, we return a new
constraint set that evaluates to `true` when there was _any_ assignment
of the removed typevars that caused the old constraint set to evaluate
to `true`.

When comparing a generic constraint set, we add its typevars to the
`inferable` set, and figure out whatever constraints would allow any
specialization to satisfy the check. We then use the new existential
quantification operator to remove those new typevars, since the caller
doesn't (and shouldn't) know anything about them.

---------

Co-authored-by: David Peter <sharkdp@users.noreply.github.com>
2025-11-17 13:43:37 -05:00
..
ruff Fix analyze graph tests on windows (#21481) 2025-11-16 18:27:07 +00:00
ruff_annotate_snippets
ruff_benchmark [ty] Faster subscript assignment checks for (unions of) TypedDicts (#21378) 2025-11-12 20:16:38 +01:00
ruff_cache
ruff_db [ty] Support for notebooks in VS Code (#21175) 2025-11-13 13:23:19 +01:00
ruff_dev Update Rust toolchain to 1.91 (#21179) 2025-11-01 01:50:58 +00:00
ruff_diagnostics
ruff_formatter [ty] Use "cannot" consistently over "can not" (#21255) 2025-11-03 10:38:20 -05:00
ruff_graph analyze: Add option to skip over imports in TYPE_CHECKING blocks (#21472) 2025-11-16 12:30:24 +00:00
ruff_index
ruff_linter [refurb] Fix FURB103 autofix (#21454) 2025-11-16 09:32:41 +01:00
ruff_macros Document when a rule was added (#21035) 2025-10-23 14:48:41 -04:00
ruff_memory_usage [ty] Clean up inherited generic contexts (#20647) 2025-10-03 13:55:43 -04:00
ruff_notebook [ty] Respect notebook cell boundaries when adding an auto import (#21322) 2025-11-13 18:58:08 +01:00
ruff_options_metadata
ruff_python_ast [ruff] Ignore str() when not used for simple conversion (RUF065) (#21330) 2025-11-10 18:04:41 -05:00
ruff_python_ast_integration_tests
ruff_python_codegen Configurable "unparse mode" for ruff_python_codegen::Generator (#21041) 2025-10-24 15:44:48 +00:00
ruff_python_formatter Avoid syntax error when formatting attribute expressions with outer parentheses, parenthesized value, and trailing comment on value (#20418) 2025-11-17 09:11:36 -06:00
ruff_python_importer [ty] Respect notebook cell boundaries when adding an auto import (#21322) 2025-11-13 18:58:08 +01:00
ruff_python_index
ruff_python_literal
ruff_python_parser [ty] name is parameter and global is a syntax error (#21312) 2025-11-14 18:15:34 +00:00
ruff_python_semantic [pyflakes] Revert to stable behavior if imports for module lie in alternate branches for F401 (#20878) 2025-10-27 10:23:36 -05:00
ruff_python_stdlib
ruff_python_trivia
ruff_python_trivia_integration_tests
ruff_server Fix missing diagnostics for notebooks (#21156) 2025-10-31 01:16:43 +00:00
ruff_source_file
ruff_text_size [ruff] Update schemars to v1 (#20942) 2025-10-20 08:59:52 +02:00
ruff_wasm Bump 0.14.5 (#21435) 2025-11-13 14:37:31 -05:00
ruff_workspace analyze: Add option to skip over imports in TYPE_CHECKING blocks (#21472) 2025-11-16 12:30:24 +00:00
ty [ty] Improve diagnostic range for non-subscriptable diagnostics (#21461) 2025-11-14 21:15:14 +00:00
ty_combine
ty_completion_eval [ty] Sync vendored typeshed stubs (#21466) 2025-11-15 17:12:32 +00:00
ty_ide [ty] suppress invalid suggestions in import statements (#21484) 2025-11-17 09:58:49 -05:00
ty_project [ty] Fix --exclude and src.exclude merging (#21341) 2025-11-10 12:52:45 +01:00
ty_python_semantic [ty] Constraint sets compare generic callables correctly (#21392) 2025-11-17 13:43:37 -05:00
ty_server [ty] Inlay hint call argument location (#20349) 2025-11-17 11:33:09 +01:00
ty_static
ty_test [ty] Provide proper error on dangling revealed (#21416) 2025-11-16 08:34:54 +00:00
ty_vendored [ty] Sync vendored typeshed stubs (#21466) 2025-11-15 17:12:32 +00:00
ty_wasm [ty] Inlay hint call argument location (#20349) 2025-11-17 11:33:09 +01:00