Skip to content

refactor(ruff): remove ruff per file exemptions (#2120)#2139

Open
cfxegbert wants to merge 13 commits into
AcademySoftwareFoundation:mainfrom
cfxegbert:refactor/2120-remove-ruff-per-file-exemptions
Open

refactor(ruff): remove ruff per file exemptions (#2120)#2139
cfxegbert wants to merge 13 commits into
AcademySoftwareFoundation:mainfrom
cfxegbert:refactor/2120-remove-ruff-per-file-exemptions

Conversation

@cfxegbert

@cfxegbert cfxegbert commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Branch summary: refactor/2120-remove-ruff-per-file-exemptions

13 commits ahead of main (issue #2120). 16 files changed, +55 / −84 lines.

Goal

Remove most Ruff per-file-ignores and fix the underlying lint issues in code instead of suppressing them globally per file.

Config & CI

  • ruff.toml: Dropped ~20 per-file ignore entries (tests, bind, resolver, CLI, rezgui, install/setup scripts, etc.). Only one remains:
    • src/rezplugins/release_vcs/git.pyF821 (undefined git in export(); uses the git Python package, which isn’t installed — noted as a known bug used by rez-diff / diff_packages.py)
  • ruff.toml + .github/workflows/ruff.yaml: Exclude src/support/ from Ruff entirely.
  • src/rez/tests/ruff.toml (new): Extends root config and treats rex builtins (env, command, etc.) as known names in tests.

Code fixes (replacing suppressions)

Area Change
Type comparisons (E721) package_order.py, rezgui/objects/Config.py — use type(x) is type(y)
String concatenation (ISC002) cli/_main.py — f-strings instead of implicit concatenation
Unused import (F401) ContextToolsWidget.py — removed unused app import; install.py — removed unused virtualenv import
Lambda assignment (E731) TimestampWidget.py — inline lambda
Undefined names (F821) resolver.py — TYPE_CHECKING imports; bind/_pymodule.py — inline # noqa: F821 on env
Ambiguous class (E742) test_formatter.py — inline # noqa: E742 on class I
Import order (E402) install.py, setup.py, release-rez.py — inline # noqa: E402
Datetime (DTZ011) release-rez.py — inline # noqa: DTZ011 on date.today()
Git VCS git.py — added missing retain_cwd import (used by export(), which diff_packages.py calls)

Not in committed changes

diff_packages.py is unchanged on this branch; it’s relevant context because it calls GitReleaseVCS.export(), which is why the git.py F821 exemption remains.

I used some help from an LLM to create the summary for this PR

cfxegbert added 13 commits June 25, 2026 16:28
Signed-off-by: Robert Minsk <robertminsk@yahoo.com>
Signed-off-by: Robert Minsk <robertminsk@yahoo.com>
Signed-off-by: Robert Minsk <robertminsk@yahoo.com>
Signed-off-by: Robert Minsk <robertminsk@yahoo.com>
Signed-off-by: Robert Minsk <robertminsk@yahoo.com>
Signed-off-by: Robert Minsk <robertminsk@yahoo.com>
@cfxegbert
cfxegbert requested a review from a team as a code owner June 26, 2026 01:34
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 35.29412% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.30%. Comparing base (9c1cdee) to head (1706398).

Files with missing lines Patch % Lines
src/rez/bind/_pymodule.py 0.00% 3 Missing ⚠️
src/rez/cli/_main.py 0.00% 3 Missing ⚠️
src/rez/package_order.py 71.42% 1 Missing and 1 partial ⚠️
src/rez/resolver.py 0.00% 2 Missing ⚠️
src/rez/config.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2139      +/-   ##
==========================================
- Coverage   61.31%   61.30%   -0.02%     
==========================================
  Files         164      164              
  Lines       20568    20573       +5     
  Branches     3575     3576       +1     
==========================================
+ Hits        12611    12612       +1     
- Misses       7085     7088       +3     
- Partials      872      873       +1     

☔ View full report in Codecov by Harness.
📢 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.

@cfxegbert cfxegbert changed the title Refactor/2120 remove ruff per file exemptions refactor: remove ruff per file exemptions (#2120) Jun 26, 2026
@cfxegbert cfxegbert changed the title refactor: remove ruff per file exemptions (#2120) refactor(ruff): remove ruff per file exemptions (#2120) Jun 29, 2026

@JeanChristopheMorinPerso JeanChristopheMorinPerso left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let a few comments. Let me know what you think

- '!src/rez/utils/_version.py'
- '!src/rez/vendor/**'
- '!src/rez/data/**'
- '!src/support/**'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Umm, support is something we would want to lint eventually...

Comment thread src/rez/bind/_pymodule.py

def commands() -> None:
env.PYTHONPATH.append('{this.root}/python')
env.PYTHONPATH.append('{this.root}/python') # noqa: F821

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would prefer if we use qualified names instead of IDs.

Comment thread src/rez/tests/ruff.toml
extend = "../../../ruff.toml"

# Treat rex as builtin
builtins = [

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This feels "risky" to me. Can we instead use https://github.com/AcademySoftwareFoundation/rez/blob/main/src/rez/utils/lint_helper.py where these are referenced?

Comment thread src/rez/package_order.py

def __eq__(self, other):
return type(self) == type(other) and str(self) == str(other) # noqa: E721
if isinstance(other, type(self)):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are we 100% sure that this will not create a problem? This is different than type() == type(). isinstance will check if an object is an instance of a class or a subclass.

Comment thread src/rez/package_order.py

def __eq__(self, other):
return type(self) == type(other) # noqa: E721
return type(self) is type(other)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do we use is here while we are using isinstance higher?

Comment thread src/rez/package_order.py
return type(self) == type(other) and str(self) == str(other) # noqa: E721
if isinstance(other, type(self)):
return str(self) == str(other)
return NotImplemented

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why return NotImplemented here and not in other classes?

Comment thread install.py
import venv
except ImportError:
USE_VIRTUALENV = True
import virtualenv

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we keep this just to make sure that there's an import failure if it's not installed?

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.

2 participants