Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a new rule for FastApi routes #11637

Closed
TomerBin opened this issue May 31, 2024 · 2 comments
Closed

Implement a new rule for FastApi routes #11637

TomerBin opened this issue May 31, 2024 · 2 comments
Labels
rule Implementing or modifying a lint rule

Comments

@TomerBin
Copy link
Contributor

TomerBin commented May 31, 2024

Hi there,

I recently came up with the idea to remove the redundant usage of the response_model keyword in FastAPI routes. FastAPI looks at the return type annotation of the decorated function by default, so using response_model while having a return type annotation with the same value is a code duplication that should be avoided.

As someone new to Rust and contributing to Ruff, I took this opportunity to learn and implemented this rule in #11579. If you find this rule aligns with Ruff’s goals, I would kindly ask for a code review.

Thank you!
Tomer Bin

@charliermarsh charliermarsh added rule Implementing or modifying a lint rule needs-decision Awaiting a decision from a maintainer labels May 31, 2024
@yannayh
Copy link

yannayh commented Jun 1, 2024

As someone using FastAPI that had no idea that this is a code duplication (which exists in my project unfortunately 😅) I would love for this rule to be implemented 👍🏼

@charliermarsh
Copy link
Member

Added in #11579 -- thanks @TomerBin!

@charliermarsh charliermarsh removed the needs-decision Awaiting a decision from a maintainer label Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Implementing or modifying a lint rule
Projects
None yet
Development

No branches or pull requests

3 participants