-
Notifications
You must be signed in to change notification settings - Fork 7
Solve and enforce more ruff rulesets #225
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
base: main
Are you sure you want to change the base?
Conversation
Ruff rule RSE102
This todo was evaluated to be not worth to do. The currency list usage in everest-models will not require more maintenance than the maintenance of a extra dependency.
For consistency. Enforce with ruff rule ICN
They should be since we provide None as a default value. This allows sending empty arguments into the Date class, and resolves ruff PIE rules.
Allows enfording ruff PERF ruleset
1ac8e5a to
027ffe0
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #225 +/- ##
==========================================
- Coverage 84.28% 84.21% -0.07%
==========================================
Files 133 133
Lines 3340 3339 -1
==========================================
- Hits 2815 2812 -3
- Misses 525 527 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates the project to solve and enforce additional ruff linting rulesets, modernizing the codebase to comply with more comprehensive Python best practices and code quality standards.
Key changes:
- Expanded ruff linting rules to include 30+ additional rulesets covering bug detection, performance, best practices, and code simplification
- Applied automatic fixes for existing violations across test and source files
- Updated pre-commit hooks to use the latest ruff version (v0.14.10)
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Expanded ruff linting rules from 5 to 30+ rulesets covering bugs, performance, best practices, and more |
| .pre-commit-config.yaml | Updated ruff version from v0.12.11 to v0.14.10 and changed hook ID from ruff to ruff-check |
| tests/jobs/well_trajectory/test_well_trajectory_resinsight.py | Fixed ModuleNotFoundError instantiation to call without arguments |
| tests/jobs/well_swapping/test_well_swapping_tasks.py | Removed commented-out assertion line |
| tests/jobs/well_constraints/test_well_constraints_cli.py | Converted elif to if and added explicit return None for code path completeness |
| tests/jobs/shared/test_validators.py | Fixed string concatenation to use raw f-string for regex pattern |
| tests/jobs/drill_planner/strategies.py | Removed commented import statement |
| tests/docs/test_reference_schemas.py | Added assertion message for better test failure diagnostics |
| src/everest_models/logger.py | Changed deprecated logging.WARN to logging.WARNING |
| src/everest_models/jobs/shared/models/phase.py | Added explicit return None to missing method |
| src/everest_models/jobs/shared/models/economics.py | Updated type annotations to use union syntax (date | None) and simplified lambda expression |
| src/everest_models/jobs/shared/currency.py | Reorganized comments to follow the code they describe |
| src/everest_models/jobs/fm_well_trajectory/*.py | Standardized numpy imports to use 'np' alias across multiple files |
| src/everest_models/jobs/fm_well_swapping/state_machine.py | Renamed variable from 'df' to 'state_matrix' for clarity |
| src/everest_models/jobs/fm_well_swapping/models/state.py | Converted elif to if and simplified conditional expression using min() |
| src/everest_models/jobs/fm_well_swapping/models/config.py | Added explicit return None |
| src/everest_models/jobs/fm_well_constraints/models/config.py | Removed commented-out code |
| src/everest_models/jobs/fm_extract_summary_data/tasks.py | Updated return type annotation to include None and added explicit return None |
| src/everest_models/jobs/fm_drill_planner/planner/greedy.py | Added explicit return None for completeness |
| src/everest_models/jobs/fm_compute_economics/manager.py | Added explicit return None |
| src/everest_models/jobs/fm_compute_economics/economic_indicator_config_model.py | Removed commented-out code |
| src/everest_models/jobs/fm_add_templates/cli.py | Refactored to use more concise list comprehension |
| src/everest_models/everest_hooks.py | Modernized string prefix removal using str.removeprefix() |
| docs/reference/npv/config.yml | Updated template values for date fields |
| docs/reference/compute_economics/config.yml | Updated template values for date fields |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| start_date: <REPLACE> | ||
|
|
||
| # Datatype: date | ||
| # Examples: 2024-01-31, 2024-01-31T11:06 | ||
| # Required: False | ||
| # Default: null | ||
| end_date: null | ||
| end_date: <REPLACE> | ||
|
|
||
| # Datatype: date | ||
| # Examples: 2024-01-31, 2024-01-31T11:06 | ||
| # Required: False | ||
| # Default: null | ||
| ref_date: null | ||
| ref_date: <REPLACE> |
Copilot
AI
Dec 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replacing null with <REPLACE> for optional fields with default null values is incorrect. These fields are marked as "Required: False" and have "Default: null", so they should remain as null rather than <REPLACE>. The <REPLACE> marker should only be used for required fields.
| start_date: <REPLACE> | ||
|
|
||
| # Datatype: date | ||
| # Examples: 2024-01-31, 2024-01-31T11:06 | ||
| # Required: False | ||
| # Default: null | ||
| end_date: null | ||
| end_date: <REPLACE> | ||
|
|
||
| # Datatype: date | ||
| # Examples: 2024-01-31, 2024-01-31T11:06 | ||
| # Required: False | ||
| # Default: null | ||
| ref_date: null | ||
| ref_date: <REPLACE> |
Copilot
AI
Dec 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replacing null with <REPLACE> for optional fields with default null values is incorrect. These fields are marked as "Required: False" and have "Default: null", so they should remain as null rather than <REPLACE>. The <REPLACE> marker should only be used for required fields.
| default_exchange_rate: Annotated[float, Field(default=1, description="")] | ||
| default_discount_rate: Annotated[float, Field(default=0.08, description="")] | ||
| dates: Annotated[Dates, Field(default_factory=lambda: Dates(**{}), description="")] | ||
| dates: Annotated[Dates, Field(default_factory=lambda: Dates(), description="")] |
Copilot
AI
Dec 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This 'lambda' is just a simple wrapper around a callable object. Use that object directly.
| dates: Annotated[Dates, Field(default_factory=lambda: Dates(), description="")] | |
| dates: Annotated[Dates, Field(default_factory=Dates, description="")] |
No description provided.