ruff/crates/red_knot_python_semantic/src
David Peter b662c3ff7e
[red-knot] Add support for assert_never (#17287)
## Summary

We already have partial "support" for `assert_never`, because it is
annotated as
```pyi
def assert_never(arg: Never, /) -> Never: ...
```
in typeshed. So we already emit a `invalid-argument-type` diagnostic if
the argument type to `assert_never` is not assignable to `Never`.

That is not enough, however. Gradual types like `Any`, `Unknown`,
`@Todo(…)` or `Any & int` can be assignable to `Never`. Which means that
we didn't issue any diagnostic in those cases.

Also, it seems like `assert_never` deserves a dedicated diagnostic
message, not just a generic "invalid argument type" error.

## Test Plan

New Markdown tests.
2025-04-08 09:31:49 +02:00
..
module_resolver [red-knot] Support stub packages (#17204) 2025-04-07 14:40:50 +02:00
semantic_index [red-knot] Reachability analysis (#17199) 2025-04-08 08:37:20 +02:00
types [red-knot] Add support for assert_never (#17287) 2025-04-08 09:31:49 +02:00
util [red-knot] Improve ergonomics for the PySlice trait (#13983) 2024-10-29 20:40:59 +00:00
ast_node_ref.rs Fixing various spelling errors (#16924) 2025-03-23 08:08:40 +00:00
db.rs [red-knot] Fix python setting in mdtests, and rewrite a site-packages test as an mdtest (#17222) 2025-04-06 18:24:32 +01:00
lib.rs [red-knot] Fix python setting in mdtests, and rewrite a site-packages test as an mdtest (#17222) 2025-04-06 18:24:32 +01:00
lint.rs Add knot.toml schema (#15735) 2025-02-07 10:59:40 +01:00
list.rs [red-knot] Don't use separate ID types for each alist (#16415) 2025-02-28 14:55:55 -05:00
module_name.rs [red-knot] Add initial support for * imports (#16923) 2025-03-24 17:15:58 +00:00
node_key.rs [red-knot] Use memory address as AST node key (#14317) 2024-11-13 14:35:54 +01:00
program.rs [red-knot] Change venv discovery (#17099) 2025-03-31 19:39:05 +02:00
python_platform.rs [red-knot] Add --python-platform CLI option (#17284) 2025-04-07 21:04:44 +02:00
semantic_index.rs [red-knot] fix eager nested scopes handling (#16916) 2025-03-28 11:11:56 -04:00
semantic_model.rs [red-knot] Goto type definition (#16901) 2025-04-02 12:12:48 +00:00
site_packages.rs [red-knot] Discover local venv folder in cli (#16917) 2025-03-28 17:59:49 +00:00
suppression.rs Upgrade to Rust 1.86 and bump MSRV to 1.84 (#17171) 2025-04-03 15:59:44 +00:00
symbol.rs Enable overindented docs lint (#17182) 2025-04-03 20:27:11 +01:00
types.rs [red-knot] Add support for assert_never (#17287) 2025-04-08 09:31:49 +02:00
unpack.rs [red-knot] Factor out shared unpacking logic (#16595) 2025-03-28 23:52:51 +05:30