Skip to content

Update ruff version and add preview rules#848

Merged
larsevj merged 2 commits intomainfrom
fixup_ruff
Feb 5, 2026
Merged

Update ruff version and add preview rules#848
larsevj merged 2 commits intomainfrom
fixup_ruff

Conversation

@larsevj
Copy link
Collaborator

@larsevj larsevj commented Feb 4, 2026

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Feb 4, 2026

Codecov Report

❌ Patch coverage is 83.18584% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.44%. Comparing base (b4bbca4) to head (5eae456).

Files with missing lines Patch % Lines
src/subscript/csv_merge/csv_merge.py 55.55% 4 Missing ⚠️
src/subscript/casegen_upcars/casegen_upcars.py 25.00% 3 Missing ⚠️
src/subscript/field_statistics/field_statistics.py 50.00% 2 Missing ⚠️
src/subscript/fmuobs/fmuobs.py 33.33% 2 Missing ⚠️
src/subscript/sunsch/sunsch.py 80.00% 2 Missing ⚠️
...subscript/sw_model_utilities/sw_model_utilities.py 0.00% 2 Missing ⚠️
src/subscript/casegen_upcars/model.py 96.55% 1 Missing ⚠️
src/subscript/csv2ofmvol/csv2ofmvol.py 87.50% 1 Missing ⚠️
src/subscript/params2csv/params2csv.py 0.00% 1 Missing ⚠️
src/subscript/presentvalue/presentvalue.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #848   +/-   ##
=======================================
  Coverage   83.44%   83.44%           
=======================================
  Files          49       49           
  Lines        7287     7287           
=======================================
  Hits         6081     6081           
  Misses       1206     1206           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@larsevj larsevj requested review from alifbe, Copilot and rnyb February 4, 2026 13:06
Copy link

Copilot AI left a 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 ruff linter version and enables preview rules, resulting in code improvements focused on performance optimizations and code simplification. The changes primarily involve replacing list/tuple literals with set literals where appropriate, simplifying string operations, and improving variable naming conventions.

Changes:

  • Enabled ruff preview mode and added several new linting rule ignores in pyproject.toml
  • Replaced list/tuple literals with set literals in membership tests for performance
  • Simplified string operations (e.g., using += instead of concatenation, rsplit with maxsplit)
  • Improved variable naming by avoiding shadowing built-in names (e.g., class_ instead of _class)
  • Replaced os.chdir() calls with monkeypatch.chdir() in test fixtures for better test isolation

Reviewed changes

Copilot reviewed 62 out of 62 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pyproject.toml Enabled ruff preview mode and added new rule ignores
tests/*.py (multiple files) Replaced os.chdir() with monkeypatch.chdir() for test isolation
tests/utils.py Changed list to set literal in membership tests
tests/test_*.py (multiple files) Added monkeypatch parameter to test functions and fixtures
src/subscript/**/*.py (multiple files) Applied performance optimizations, simplified string operations, and improved variable naming

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@alifbe
Copy link
Collaborator

alifbe commented Feb 4, 2026

@larsevj The PR looks good to me. The copilot comments seem to make sense for me but it seems like that was exactly what it was before PR. Do they get flagged by this new ruff rule?

@larsevj
Copy link
Collaborator Author

larsevj commented Feb 5, 2026

@larsevj The PR looks good to me. The copilot comments seem to make sense for me but it seems like that was exactly what it was before PR. Do they get flagged by this new ruff rule?

I disabled the empty string rule for the tests at least, as i agree that it makes more sense for asserts, not entirely convinced about conditionals, but can reevaluate later. https://docs.astral.sh/ruff/rules/compare-to-empty-string/
Not entirely sure what you mean about them being the same before the PR?

I just scrapped that rule.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 61 out of 61 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@larsevj larsevj requested review from alifbe and removed request for alifbe February 5, 2026 09:04
Copy link
Collaborator

@alifbe alifbe left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@larsevj larsevj merged commit 4ac49d5 into main Feb 5, 2026
9 checks passed
@larsevj larsevj deleted the fixup_ruff branch February 5, 2026 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants