Skip to content

Add more ruff rules (B, PTH, RSE, SIM, C4, BLE, A)#4034

Open
mashehu wants to merge 58 commits intonf-core:devfrom
mashehu:new-ruff-rules
Open

Add more ruff rules (B, PTH, RSE, SIM, C4, BLE, A)#4034
mashehu wants to merge 58 commits intonf-core:devfrom
mashehu:new-ruff-rules

Conversation

@mashehu
Copy link
Contributor

@mashehu mashehu commented Feb 11, 2026

Additional rules we could add:

  • "C4", # flake8-comprehensions - better list/dict/set comprehensions
  • "RUF", # Ruff-specific rules - includes RUF103/104 for validating suppressions
  • "SIM", # flake8-simplify - simplifies code patterns
  • "PIE", # flake8-pie - misc lints for common issues
  • "RSE", # flake8-raise - unnecessary parentheses on raised exceptions
  • "RET", # flake8-return - unnecessary variable assignments before return
  • "ARG", # flake8-unused-arguments - finds unused function arguments
  • "BLE", # flake8-blind-except - catches blind except clauses
  • "A", # flake8-builtins - catches shadowing of Python builtins
  • "TRY", # tryceratops - exception handling best practices

@mashehu mashehu requested a review from a team February 11, 2026 10:14
@codecov
Copy link

codecov bot commented Feb 11, 2026

Codecov Report

❌ Patch coverage is 69.03226% with 144 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.48%. Comparing base (573f105) to head (4009e2e).

Files with missing lines Patch % Lines
nf_core/pipelines/schema.py 48.48% 17 Missing ⚠️
nf_core/pipelines/list.py 57.69% 11 Missing ⚠️
nf_core/synced_repo.py 31.25% 11 Missing ⚠️
nf_core/components/update.py 65.21% 8 Missing ⚠️
nf_core/pipelines/create/githubrepo.py 30.00% 7 Missing ⚠️
nf_core/pipelines/refgenie.py 0.00% 7 Missing ⚠️
nf_core/__main__.py 71.42% 6 Missing ⚠️
nf_core/pipelines/rocrate.py 66.66% 6 Missing ⚠️
nf_core/modules/modules_json.py 77.27% 5 Missing ⚠️
nf_core/modules/modules_repo.py 16.66% 5 Missing ⚠️
... and 33 more

☔ 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.

@mashehu mashehu changed the title Add more ruff rules (B, PTH) Add more ruff rules (B, PTH, RSE) Feb 11, 2026
@mashehu mashehu changed the title Add more ruff rules (B, PTH, RSE) Add more ruff rules (B, PTH, RSE, SIM) Feb 12, 2026
@mashehu mashehu changed the title Add more ruff rules (B, PTH, RSE, SIM) Add more ruff rules (B, PTH, RSE, SIM, C4) Feb 16, 2026
@mashehu mashehu changed the title Add more ruff rules (B, PTH, RSE, SIM, C4) Add more ruff rules (B, PTH, RSE, SIM, C4, BLE) Feb 16, 2026
@mashehu
Copy link
Contributor Author

mashehu commented Feb 20, 2026

hah, looks like most of these new rules are anyway part of an upcoming set of default ruff rules: astral-sh/ruff#23203

@mashehu mashehu force-pushed the new-ruff-rules branch 3 times, most recently from b2cd1b3 to dada220 Compare February 26, 2026 20:22
@mashehu mashehu changed the title Add more ruff rules (B, PTH, RSE, SIM, C4, BLE) Add more ruff rules (B, PTH, RSE, SIM, C4, BLE, A) Feb 27, 2026
"""
dir_names = os.listdir(self.local_repo_dir)
if "modules" not in dir_names:
assert self.local_repo_dir is not None, "Repository must be initialized before verifying branch"
Copy link
Contributor

Choose a reason for hiding this comment

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

assert outside test code should be avoided. See #1533 for reference.


# Remove the file extension from the path
path, _ = os.path.splitext(path)
path = str(Path(path).with_suffix(""))
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be .stem.

Sidenote: The variable path is reassigned. A new variable with the name full_name or something similar would be more descriptive and fit the function better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking into it, and I don't think that .stem would be the same here. we want to have nf-core/modules as a full_name for example, where .stem would give us just modules

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