Ruff newrules UP RET FBT FA PTH#609
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
esnguyenvan
left a comment
There was a problem hiding this comment.
Hey, thanks for this important work. Overall I agree with the changes, it makes the code nice and consistent. I have a few questions and remarks as well.
src/fastoad/models/performances/mission/segments/registered/takeoff/__init__.py
Show resolved
Hide resolved
...fastoad/models/performances/mission/mission_definition/mission_builder/structure_builders.py
Outdated
Show resolved
Hide resolved
|
In addition to the previous comments, the changes brought by this PR will make the following integration tests of CS25 break:
|
That's annoying. Thanks for the spotting! I'll look into that! |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## ruff_newrules #609 +/- ##
==============================================
Coverage 91.91% 91.91%
==============================================
Files 100 99 -1
Lines 6184 6188 +4
Branches 979 979
==============================================
+ Hits 5684 5688 +4
+ Misses 334 333 -1
- Partials 166 167 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
thanks @esnguyenvan for the remarks ! I completely reworked the logic of the _is_shape_by_conn method, just by handling in a try except the exception that we had because of the use of from future import annotations and the lazy type evaluation. |
esnguyenvan
left a comment
There was a problem hiding this comment.
Thanks for the rework, it's quite nice! It's all good for me here. It's all good with the RTA repo
|
Perfect! Let's wait for @ScottDelbecq review then! thanks Éric! |
Summary of Changes
This is the first PR introducing Ruff-based linting rules to the project to solve #610 . Currently, we rely on Codacy to enforce code quality by preventing merges when issues are detected. However, Codacy only runs checks online, requiring developers to push their code and wait for feedback before making adjustments.
The goal of this PR is to integrate Ruff checks into our pre-commit hooks, allowing developers to check their code locally before pushing. This avoids unnecessary uploads, reduces feedback delays, and ensures that developers cannot bypass rules simply by configuring Codacy to ignore them. Instead, any ignored rule must be explicitly marked with a
noqadirective in the code, along with a comment explaining the reason, or disabled globally in the Ruff configuration.Introduced Ruff Rules
This first batch enforces the following Ruff rules, which we agreed are important:
pathliboveros.path. DocumentationAdditional Changes
Separated Ruff configuration:
The Ruff configuration (
ruff.toml) has been moved out ofpyproject.tomlto keep things clean and readable, as the configuration is expected to grow over time.Ensuring the correct Ruff version in pre-commit:
The pre-commit hook now runs Ruff using Poetry to ensure the correct project-specific version is used, rather than relying on a globally installed version. This prevents potential issues, particularly in VS Code.
Modification of
_is_shape_by_connto comply with new typing rules:The function _is_shape_by_conn(key, segment_class) -> bool: has been modified in compliance with the new typing rules enforced by Ruff (especially problems with ClassVar and lazy type evaluation introduced by using builtin types).
New Dependencies
updated ruff to 0.9.9
Checklist
Additional Context
First batch of new rules, next batch is coming once these modifications are accepted.