ruff/crates
David Peter 2c57c2dc8a
[red-knot] Type narrowing for isinstance checks (#13894)
## Summary

Add type narrowing for `isinstance(object, classinfo)` [1] checks:
```py
x = 1 if flag else "a"

if isinstance(x, int):
    reveal_type(x)  # revealed: Literal[1]
```

closes #13893

[1] https://docs.python.org/3/library/functions.html#isinstance

## Test Plan

New Markdown-based tests in `narrow/isinstance.md`.

---------

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-10-23 20:51:33 +02:00
..
red_knot Upgrade salsa (#13757) 2024-10-15 11:06:32 +00:00
red_knot_python_semantic [red-knot] Type narrowing for isinstance checks (#13894) 2024-10-23 20:51:33 +02:00
red_knot_server Upgrade to Rust 1.82 (#13816) 2024-10-19 16:05:50 +02:00
red_knot_test [red-knot] Report line numbers in mdtest relative to the markdown file, not the test snippet (#13804) 2024-10-22 07:42:40 +00:00
red_knot_vendored Modernize build scripts (#13837) 2024-10-20 22:35:35 +01:00
red_knot_wasm Use backticks for code in red-knot messages (#13599) 2024-10-02 03:14:28 +00:00
red_knot_workspace [red-knot] rename {Class,Module,Function} => {Class,Module,Function}Literal (#13873) 2024-10-22 22:10:53 +02:00
ruff Modernize build scripts (#13837) 2024-10-20 22:35:35 +01:00
ruff_benchmark Bump MSRV to Rust 1.80 (#13826) 2024-10-20 10:55:36 +02:00
ruff_cache Fix cache key collisions for paths with separators (#12159) 2024-07-03 07:36:46 -05:00
ruff_db Speed up mdtests (#13832) 2024-10-21 20:06:41 +01:00
ruff_dev Alternate quotes for strings inside f-strings in preview (#13860) 2024-10-23 07:57:53 +02:00
ruff_diagnostics [Minor typo] Fix article in "an fix" (#12797) 2024-08-10 21:22:00 -04:00
ruff_formatter Use backticks for code in red-knot messages (#13599) 2024-10-02 03:14:28 +00:00
ruff_graph Bump MSRV to Rust 1.80 (#13826) 2024-10-20 10:55:36 +02:00
ruff_index [red-knot] small efficiency improvements and bugfixes to use-def map building (#12373) 2024-07-18 09:24:58 -07:00
ruff_linter Fix E221 and E222 to flag missing or extra whitespace around == operator (#13890) 2024-10-23 15:02:29 +02:00
ruff_macros Upgrade to Rust 1.82 (#13816) 2024-10-19 16:05:50 +02:00
ruff_notebook Bump MSRV to Rust 1.80 (#13826) 2024-10-20 10:55:36 +02:00
ruff_python_ast Alternate quotes for strings inside f-strings in preview (#13860) 2024-10-23 07:57:53 +02:00
ruff_python_ast_integration_tests [internal] ComparableExpr (f)strings and bytes made invariant under concatenation (#13301) 2024-09-25 16:58:57 +02:00
ruff_python_codegen Simplify iteration idioms (#13834) 2024-10-20 22:25:27 +01:00
ruff_python_formatter Alternate quotes for strings inside f-strings in preview (#13860) 2024-10-23 07:57:53 +02:00
ruff_python_index Enable token-based rules on source with syntax errors (#11950) 2024-07-02 08:57:46 +00:00
ruff_python_literal Remove some unused pub functions (#11576) 2024-05-28 09:56:51 -04:00
ruff_python_parser Short circuit lex_identifier if the name is longer or shorter than any known keyword (#13815) 2024-10-19 11:07:15 +00:00
ruff_python_resolver chore(deps): update rust crate insta to v1.38.0 (#10701) 2024-04-01 15:44:30 +00:00
ruff_python_semantic Simplify iteration idioms (#13834) 2024-10-20 22:25:27 +01:00
ruff_python_stdlib Harmonise methods for distinguishing different Python source types (#13682) 2024-10-09 13:18:52 +00:00
ruff_python_trivia [red-knot] Report line numbers in mdtest relative to the markdown file, not the test snippet (#13804) 2024-10-22 07:42:40 +00:00
ruff_python_trivia_integration_tests Build CommentRanges outside the parser (#11792) 2024-06-09 09:55:17 +00:00
ruff_server Upgrade to Rust 1.82 (#13816) 2024-10-19 16:05:50 +02:00
ruff_source_file [red-knot] Report line numbers in mdtest relative to the markdown file, not the test snippet (#13804) 2024-10-22 07:42:40 +00:00
ruff_text_size [red-knot] type inference/checking test framework (#13636) 2024-10-08 12:33:19 -07:00
ruff_wasm Changelog for Ruff v0.7 (#13794) 2024-10-17 16:14:21 +00:00
ruff_workspace Simplify iteration idioms (#13834) 2024-10-20 22:25:27 +01:00