Skip to content

[FastAPI] Add sub-diagnostic explaining why a fix was unavailable (FAST002)#22565

Merged
ntBre merged 6 commits intoastral-sh:mainfrom
11happy:Extend_FAST002
Jan 27, 2026
Merged

[FastAPI] Add sub-diagnostic explaining why a fix was unavailable (FAST002)#22565
ntBre merged 6 commits intoastral-sh:mainfrom
11happy:Extend_FAST002

Conversation

@11happy
Copy link
Contributor

@11happy 11happy commented Jan 14, 2026

Summary

This PR fixes #22188 by adding autofix skipped reason as diagnostic info.

Test Plan

snapshots are updated accordingly.

Signed-off-by: Bhuminjay <bhuminjaysoni@gmail.com>
@MichaReiser MichaReiser added the diagnostics Related to reporting of diagnostics. label Jan 14, 2026
72 | pass
|
help: Replace with `typing_extensions.Annotated`
info: Fix unavailable: Cannot convert required parameter after optional parameter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the messaging here a bit confusing. It almost sounds as if there's no way to fix this violation (I'm also not fully convinced that we should add a sub-diagnostic like this, or that we should only show it when running ruff with -v).

Maybe something like: info: automatic fix is not available because

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I agree these can be worded better, let me update.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, changed the messages to be a little bit more verbose & user friendly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am also leaning towards making these subdiagnostics available in case of verbose mode(-v)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, yeah maybe this wasn't a great suggestion for a sub-diagnostic, sorry! We could also consider just adding a Fix availability note to the documentation instead.

Alternatively, it might be more helpful to phrase the sub-diagnostic as a suggestion like "Reorder the arguments to enable an automatic fix" (but probably more specific than that).

Just a couple of ideas, I'm curious what y'all think.

Copy link
Member

@MichaReiser MichaReiser Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that users face the same issue as the fix -- they have to reorder the arguments or assign a default): Should we add a message making users aware that they have to be mindful of the default argument?

This makes the message useful beyond just saying that the auto-fix isn't available.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, worded the message a little more clear with suggestion to reorder the arguments.

Signed-off-by: Bhuminjay <bhuminjaysoni@gmail.com>
@astral-sh-bot
Copy link

astral-sh-bot bot commented Jan 14, 2026

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Signed-off-by: Bhuminjay <bhuminjaysoni@gmail.com>
Signed-off-by: Bhuminjay <bhuminjaysoni@gmail.com>
Signed-off-by: Bhuminjay <bhuminjaysoni@gmail.com>
Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is looking good! I just had one suggestion to simplify the code a bit and a couple of smaller ideas about the diagnostic message itself.

Signed-off-by: Bhuminjay <bhuminjaysoni@gmail.com>
Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@ntBre ntBre changed the title FAST002 : add autofix skipped reason as diagnostic info [FastAPI] Add sub-diagnostic explaining why a fix was unavailable (FAST002) Jan 27, 2026
@ntBre ntBre merged commit a39a1df into astral-sh:main Jan 27, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

diagnostics Related to reporting of diagnostics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FAST002 (FastAPI dependency without Annotated) could be made even smarter

3 participants