Andrew Gallant
faf54c0181
ty_python_semantic: improve failed overloaded function call
...
The diagnostic now includes a pointer to the implementation definition
along with each possible overload.
This doesn't include information about *why* each overload failed. But
given the emphasis on concise output (since there can be *many*
unmatched overloads), it's not totally clear how to include that
additional information.
Fixes #274
2025-05-14 11:13:41 -04:00
Andrew Gallant
0230cbac2c
ty_python_semantic: update "no matching overload" diagnostic test
...
It looks like support for `@overload` has been added since this test was
created, so we remove the TODO and add a snippet (from #274 ).
2025-05-14 11:13:41 -04:00
Chandra Kiran G
d17557f0ae
[ty] Fix Inconsistent casing in diagnostic ( #18084 )
2025-05-14 08:26:48 +02:00
InSync
a9f7521944
[ty] Shorten snapshot names ( #18039 )
...
Co-authored-by: Micha Reiser <micha@reiser.io>
2025-05-13 18:43:19 +02:00
Alex Waygood
c0f22928bd
[ty] Add a note to the diagnostic if a new builtin is used on an old Python version ( #18068 )
...
## Summary
If the user tries to use a new builtin on an old Python version, tell
them what Python version the builtin was added on, what our inferred
Python version is for their project, and what configuration settings
they can tweak to fix the error.
## Test Plan
Snapshots and screenshots:

2025-05-13 10:08:04 -04:00
Alex Waygood
5913997c72
[ty] Improve diagnostics for assert_type and assert_never ( #18050 )
2025-05-13 13:00:20 +00:00
Alex Waygood
7e9b0df18a
[ty] Allow classes to inherit from type[Any] or type[Unknown] ( #18060 )
2025-05-12 20:30:21 -04:00
Micha Reiser
fcd858e0c8
[ty] Refine message for why a rule is enabled ( #18038 )
CI / cargo build (msrv) (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 (windows) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Waiting to run
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 / Fuzz for new ty panics (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 / 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 (push) Blocked by required conditions
[ty Playground] Release / publish (push) Waiting to run
2025-05-12 13:31:42 +02:00
Andrew Gallant
346e82b572
ty_python_semantic: add union type context to function call type errors
...
This context gets added only when calling a function through a union
type.
2025-05-09 13:40:51 -04:00
Andrew Gallant
5ea3a52c8a
ty_python_semantic: report all union diagnostic
...
This makes one very simple change: we report all call binding
errors from each union variant.
This does result in duplicate-seeming diagnostics. For example,
when two union variants are invalid for the same reason.
2025-05-09 13:40:51 -04:00
Andrew Gallant
90272ad85a
ty_python_semantic: add snapshot tests for existing union function type diagnostics
...
This is just capturing the status quo so that we can better see the
changes. I took these tests from the (now defunct) PR #17959 .
2025-05-09 13:40:51 -04:00
Andrew Gallant
b71ef8a26e
ruff_db: completely rip lint: prefix out
...
This does a deeper removal of the `lint:` prefix by removing the
`DiagnosticId::as_str` method and replacing it with `as_concise_str`. We
remove the associated error type and simplify the `Display` impl for
`DiagnosticId` as well.
This turned out to catch a `lint:` that was still in the diagnostic
output: the part that says why a lint is enabled.
2025-05-09 12:42:14 -04:00
Andrew Gallant
50c780fc8b
ty: switch to use annotate-snippets ID functionality
...
We just set the ID on the `Message` and it just does what we want in
this case. I think I didn't do this originally because I was trying to
preserve the existing rendering? I'm not sure. I might have just missed
this method.
2025-05-09 12:42:14 -04:00
Andrew Gallant
244ea27d5f
ruff_db: a small tweak to remove empty message case
...
In a subsequent commit, we're going to start using `annotate-snippets`'s
functionality for diagnostic IDs in the rendering. As part of doing
that, I wanted to remove this special casing of an empty message. I did
that independently to see what, if anything, would change. (The changes
look fine to me. They'll be tweaked again in the next commit along with
a bunch of others.)
2025-05-09 12:42:14 -04:00
Andrew Gallant
2c4cbb6e29
ty: get rid of lint: prefix in ID for diagnostic rendering
...
In #289 , we seem to have consensus that this prefix isn't really pulling
its weight.
Ref #289
2025-05-09 12:42:14 -04:00
Alex Waygood
03a4d56624
[ty] Change range of revealed-type diagnostic to be the range of the argument passed in, not the whole call ( #17980 )
2025-05-09 14:15:39 +01:00
Alex Waygood
da8540862d
[ty] Make unused-ignore-comment disabled by default for now ( #17955 )
2025-05-08 17:21:34 +01:00
Micha Reiser
d608eae126
[ty] Ignore possibly-unresolved-reference by default ( #17934 )
2025-05-08 17:44:56 +02:00
Alex Waygood
51cef5a72b
[ty] Recognise functions containing yield from expressions as being generator functions ( #17930 )
2025-05-07 23:29:44 +01:00
Alex Waygood
74fe7982ba
[ty] Sort collected diagnostics before snapshotting them in mdtest ( #17926 )
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo build (msrv) (push) Blocked by required conditions
CI / Determine changes (push) Waiting to run
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 / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Waiting to run
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 / Fuzz for new ty panics (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 / 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 (push) Blocked by required conditions
[ty Playground] Release / publish (push) Waiting to run
2025-05-07 18:23:22 +01:00
Alex Waygood
2ec0d7e072
[ty] Improve UX for [duplicate-base] diagnostics ( #17914 )
2025-05-07 15:27:37 +00:00
Charlie Marsh
a2e9a7732a
Update class literal display to use <class 'Foo'> style ( #17889 )
...
## Summary
Closes https://github.com/astral-sh/ruff/issues/17238 .
2025-05-06 20:11:25 -04:00
Micha Reiser
b2de749c32
Add a note to diagnostics why the rule is enabled ( #17854 )
2025-05-06 20:29:03 +02:00
Alex Waygood
2f9992b6ef
[ty] Fix duplicate diagnostics for unresolved module when an import from statement imports multiple members ( #17886 )
2025-05-06 12:37:10 +01:00
Alex Waygood
bb6c7cad07
[ty] Fix false-positive [invalid-return-type] diagnostics on generator functions ( #17871 )
2025-05-05 21:44:59 +00:00
Micha Reiser
b51c4f82ea
Rename Red Knot ( #17820 )
2025-05-03 19:49:15 +02:00