From 5a7212c5be7e8d2fb4ce058f1fc1a2218d05a483 Mon Sep 17 00:00:00 2001 From: Robert Minsk Date: Mon, 25 May 2026 16:05:23 -0700 Subject: [PATCH 01/13] refactor(ruff): get rid of noqa warning (#2120) Signed-off-by: Robert Minsk --- src/rez/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rez/config.py b/src/rez/config.py index b1c5f67d6..74a4b1f76 100644 --- a/src/rez/config.py +++ b/src/rez/config.py @@ -659,7 +659,7 @@ def sourced_filepaths(self) -> list[str]: Returns: List of str: The sourced files. """ - _ = self._data # noqa; force a config load + _ = self._data # force a config load # noqa return self._sourced_filepaths or [] @cached_property From 636fb4e8a431b803b73234a618fa04b159099b78 Mon Sep 17 00:00:00 2001 From: Robert Minsk Date: Mon, 25 May 2026 16:22:12 -0700 Subject: [PATCH 02/13] refactor(ruff): fix concatenated string literals over multiple lines (#2120) Signed-off-by: Robert Minsk --- ruff.toml | 3 --- src/rez/cli/_main.py | 9 +++------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/ruff.toml b/ruff.toml index d38b079c4..311ac2338 100644 --- a/ruff.toml +++ b/ruff.toml @@ -123,9 +123,6 @@ ignore = [ "src/rez/resolver.py" = [ "F821" # Undefined name ] -"src/rez/cli/_main.py" = [ - "ISC002" # Implicitly concatenated string literals over multiple lines -] "src/rez/cli/release.py" = [ "F821" # Undefined name ] diff --git a/src/rez/cli/_main.py b/src/rez/cli/_main.py index c5733a1ce..a4293447f 100644 --- a/src/rez/cli/_main.py +++ b/src/rez/cli/_main.py @@ -35,14 +35,11 @@ def __call__(self, parser_name, parser): error_msg = None if not mod.__doc__: - error_msg = "command module %s must have a module-level " \ - "docstring (used as the command help)" % self.module_name + error_msg = f"command module {self.module_name} must have a module-level docstring (used as the command help)" if not hasattr(mod, 'command'): - error_msg = "command module %s must provide a command() " \ - "function" % self.module_name + error_msg = f"command module {self.module_name} must provide a command() function" if not hasattr(mod, 'setup_parser'): - error_msg = "command module %s must provide a setup_parser() " \ - "function" % self.module_name + error_msg = f"command module {self.module_name} must provide a setup_parser() function" if error_msg: print(error_msg, file=sys.stderr) return SUPPRESS From 21149b649d30dd8eef5780fc961b55de4998ed9c Mon Sep 17 00:00:00 2001 From: Robert Minsk Date: Mon, 25 May 2026 16:48:59 -0700 Subject: [PATCH 03/13] refactor(ruff): fix use is and is not for type comparisons (#2120) Signed-off-by: Robert Minsk --- ruff.toml | 3 --- src/rez/package_order.py | 22 +++++++++------------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/ruff.toml b/ruff.toml index 311ac2338..1e61c94de 100644 --- a/ruff.toml +++ b/ruff.toml @@ -126,9 +126,6 @@ ignore = [ "src/rez/cli/release.py" = [ "F821" # Undefined name ] -"src/rez/package_order.py" = [ - "E721" # Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks -] "src/rez/tests/test_formatter.py" = [ "E742" # Ambiguous class name: `I` ] diff --git a/src/rez/package_order.py b/src/rez/package_order.py index d8c755575..df813ae19 100644 --- a/src/rez/package_order.py +++ b/src/rez/package_order.py @@ -193,7 +193,9 @@ def __str__(self) -> str: raise NotImplementedError def __eq__(self, other): - return type(self) == type(other) and str(self) == str(other) # noqa: E721 + if isinstance(other, type(self)): + return str(self) == str(other) + return NotImplemented def __ne__(self, other) -> bool: return not self == other @@ -220,7 +222,7 @@ def __str__(self) -> str: return "{}" def __eq__(self, other): - return type(self) == type(other) # noqa: E721 + return type(self) is type(other) def to_pod(self) -> dict[str, Any]: """ @@ -266,10 +268,7 @@ def __str__(self) -> str: return str(self.descending) def __eq__(self, other): - return ( # noqa: E721 - type(self) == type(other) - and self.descending == other.descending - ) + return type(self) is type(other) and self.descending == other.descending def to_pod(self) -> dict[str, Any]: """ @@ -345,8 +344,8 @@ def __str__(self) -> str: return str((items, str(self.default_order))) def __eq__(self, other): - return ( # noqa: E721 - type(other) == type(self) + return ( + type(other) is type(self) and self.order_dict == other.order_dict and self.default_order == other.default_order ) @@ -437,10 +436,7 @@ def __str__(self) -> str: return str(self.first_version) def __eq__(self, other): - return ( # noqa: E721 - type(other) == type(self) - and self.first_version == other.first_version - ) + return type(other) is type(self) and self.first_version == other.first_version def to_pod(self) -> dict[str, Any]: """ @@ -601,7 +597,7 @@ def __str__(self) -> str: def __eq__(self, other): return ( # noqa: E721 - type(other) == type(self) + type(other) is type(self) and self.timestamp == other.timestamp and self.rank == other.rank ) From 5f8d44177e3a5082294de89ab37851a55d5ace3c Mon Sep 17 00:00:00 2001 From: Robert Minsk Date: Mon, 25 May 2026 17:04:05 -0700 Subject: [PATCH 04/13] refactor(ruff): fix line too long (#2120) Signed-off-by: Robert Minsk --- src/rez/cli/_main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/rez/cli/_main.py b/src/rez/cli/_main.py index a4293447f..9a2be6bf5 100644 --- a/src/rez/cli/_main.py +++ b/src/rez/cli/_main.py @@ -35,7 +35,10 @@ def __call__(self, parser_name, parser): error_msg = None if not mod.__doc__: - error_msg = f"command module {self.module_name} must have a module-level docstring (used as the command help)" + error_msg = ( + f"command module {self.module_name} must have a module-level docstring " + "(used as the command help)" + ) if not hasattr(mod, 'command'): error_msg = f"command module {self.module_name} must provide a command() function" if not hasattr(mod, 'setup_parser'): From 6e8a8875c6c1b208ef249f72b161e4d481c990b8 Mon Sep 17 00:00:00 2001 From: Robert Minsk Date: Mon, 25 May 2026 17:16:23 -0700 Subject: [PATCH 05/13] refactor(ruff): suppress warning in rez-release (#2120) Signed-off-by: Robert Minsk --- release-rez.py | 4 ++-- ruff.toml | 7 ------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/release-rez.py b/release-rez.py index 89826215f..9cb153b6c 100644 --- a/release-rez.py +++ b/release-rez.py @@ -24,7 +24,7 @@ src_path = os.path.join(source_path, "src") sys.path.insert(0, src_path) -from rez.utils._version import _rez_version +from rez.utils._version import _rez_version # noqa: E402 def get_github_repo_owner(): @@ -212,7 +212,7 @@ def generate_changelog_entry(issue_nums): ) # print title section - today = date.today() + today = date.today() # noqa: DTZ011 print( "## v%s (%d-%02d-%02d)" % (_rez_version, today.year, today.month, today.day) diff --git a/ruff.toml b/ruff.toml index 1e61c94de..2bc81c450 100644 --- a/ruff.toml +++ b/ruff.toml @@ -108,9 +108,6 @@ ignore = [ ] [lint.per-file-ignores] -"__init__.py" = [ - "D104" # undocumented-public-package -] "src/rez/tests/*.py" = [ "F821" # Undefined name ] @@ -144,10 +141,6 @@ ignore = [ "src/support/package_utils/set_authors.py" = [ "INP001" # part of an implicit namespace package ] -"./release-rez.py" = [ - "E402", # Module level import not at top of file - "DTZ011" # `datetime.date.today()` used -] "./install.py" = [ "E402", # Module level import not at top of file "F401" # "virtualenv" imported but unused From bbe136024a6ac89696c169a42fe4e77af849df97 Mon Sep 17 00:00:00 2001 From: Robert Minsk Date: Mon, 25 May 2026 17:22:32 -0700 Subject: [PATCH 06/13] refactor(ruff): supress module level import not at top of file (#2120) Signed-off-by: Robert Minsk --- ruff.toml | 3 --- setup.py | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/ruff.toml b/ruff.toml index 2bc81c450..86847d85a 100644 --- a/ruff.toml +++ b/ruff.toml @@ -145,9 +145,6 @@ ignore = [ "E402", # Module level import not at top of file "F401" # "virtualenv" imported but unused ] -"./setup.py" = [ - "E402" # Module level import not at top of file -] [lint.flake8-annotations] # Allow "Any" for dynamically typed *args and **kwargs arguments diff --git a/setup.py b/setup.py index 58aeacca8..0b81051ae 100644 --- a/setup.py +++ b/setup.py @@ -19,8 +19,8 @@ src_path = os.path.join(source_path, "src") sys.path.insert(0, src_path) -from rez.utils._version import _rez_version -from rez.cli._entry_points import get_specifications +from rez.utils._version import _rez_version # noqa: E402 +from rez.cli._entry_points import get_specifications # noqa: E402 def find_files(pattern, path=None, root="rez"): From 9daff766dbc6d9f92c3d51afa770da812720eaf1 Mon Sep 17 00:00:00 2001 From: Robert Minsk Date: Mon, 25 May 2026 17:24:33 -0700 Subject: [PATCH 07/13] refactor(ruff): remove unused import (#2120) Signed-off-by: Robert Minsk --- install.py | 3 +-- ruff.toml | 4 ---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/install.py b/install.py index f6ded0c9b..6f065b963 100644 --- a/install.py +++ b/install.py @@ -18,7 +18,6 @@ import venv except ImportError: USE_VIRTUALENV = True - import virtualenv source_path = os.path.dirname(os.path.realpath(__file__)) @@ -29,7 +28,7 @@ # though rez is not yet built. # from rez.utils._version import _rez_version # noqa: E402 -from rez.utils.filesystem import safe_rmtree +from rez.utils.filesystem import safe_rmtree # noqa: E402 from rez.utils.which import which # noqa: E402 from rez.cli._entry_points import get_specifications # noqa: E402 from rez.vendor.distlib.scripts import ScriptMaker # noqa: E402 diff --git a/ruff.toml b/ruff.toml index 86847d85a..1f56bf3db 100644 --- a/ruff.toml +++ b/ruff.toml @@ -141,10 +141,6 @@ ignore = [ "src/support/package_utils/set_authors.py" = [ "INP001" # part of an implicit namespace package ] -"./install.py" = [ - "E402", # Module level import not at top of file - "F401" # "virtualenv" imported but unused -] [lint.flake8-annotations] # Allow "Any" for dynamically typed *args and **kwargs arguments From 5fc63cccb9103d4ad5c0be83bdd1e529fbe6b778 Mon Sep 17 00:00:00 2001 From: Robert Minsk Date: Mon, 25 May 2026 17:32:55 -0700 Subject: [PATCH 08/13] refactor(ruff): various rezgui fixes (#2120) Signed-off-by: Robert Minsk --- ruff.toml | 9 --------- src/rezgui/objects/Config.py | 2 +- src/rezgui/widgets/ContextToolsWidget.py | 1 - src/rezgui/widgets/TimestampWidget.py | 3 +-- 4 files changed, 2 insertions(+), 13 deletions(-) diff --git a/ruff.toml b/ruff.toml index 1f56bf3db..871f9c2a1 100644 --- a/ruff.toml +++ b/ruff.toml @@ -126,15 +126,6 @@ ignore = [ "src/rez/tests/test_formatter.py" = [ "E742" # Ambiguous class name: `I` ] -"src/rezgui/objects/Config.py" = [ - "E721" # Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks -] -"src/rezgui/widgets/ContextToolsWidget.py" = [ - "F401" # "rezgui.objects.App.app" imported but unused -] -"src/rezgui/widgets/TimestampWidget.py" = [ - "E731" # Do not assign a `lambda` expression, use a `def` -] "src/rezplugins/release_vcs/git.py" = [ "F821" # Undefined name ] diff --git a/src/rezgui/objects/Config.py b/src/rezgui/objects/Config.py index bd3b7b6aa..bd3a0a68b 100644 --- a/src/rezgui/objects/Config.py +++ b/src/rezgui/objects/Config.py @@ -26,7 +26,7 @@ def value(self, key, type_=None): if type_ is None: default = self._default_value(key) val = self._value(key, default) - if type(val) == type(default): + if type(val) is type(default): return val else: return self._convert_value(val, type(default)) diff --git a/src/rezgui/widgets/ContextToolsWidget.py b/src/rezgui/widgets/ContextToolsWidget.py index 8d573dffe..4d71ca1dc 100644 --- a/src/rezgui/widgets/ContextToolsWidget.py +++ b/src/rezgui/widgets/ContextToolsWidget.py @@ -7,7 +7,6 @@ from rezgui.models.ContextModel import ContextModel from rezgui.mixins.ContextViewMixin import ContextViewMixin from rezgui.util import get_icon -from rezgui.objects.App import app class _TreeNode(QtWidgets.QLabel): diff --git a/src/rezgui/widgets/TimestampWidget.py b/src/rezgui/widgets/TimestampWidget.py index 698afe903..b5ea15fa9 100644 --- a/src/rezgui/widgets/TimestampWidget.py +++ b/src/rezgui/widgets/TimestampWidget.py @@ -63,10 +63,9 @@ def _stateChanged(self, state) -> None: self.refresh() def _selectPackage(self) -> None: - fn = lambda x: bool(x.timestamp) dlg = BrowsePackageDialog(context_model=self.context_model, parent=self.parentWidget(), - package_selectable_callback=fn) + package_selectable_callback=lambda x: bool(x.timestamp)) dlg.exec_() if dlg.package: self.set_time(dlg.package.timestamp) From 2805862b8809840022b899d0984d69e5fc2608d5 Mon Sep 17 00:00:00 2001 From: Robert Minsk Date: Mon, 25 May 2026 17:47:18 -0700 Subject: [PATCH 09/13] refactor(ruff): add missing import (#2120) Signed-off-by: Robert Minsk --- src/rezplugins/release_vcs/git.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rezplugins/release_vcs/git.py b/src/rezplugins/release_vcs/git.py index aad9bce6b..2543d1428 100644 --- a/src/rezplugins/release_vcs/git.py +++ b/src/rezplugins/release_vcs/git.py @@ -6,6 +6,7 @@ Git version control """ from rez.release_vcs import ReleaseVCS +from rez.utils.filesystem import retain_cwd from rez.utils.logging_ import print_error, print_debug from rez.exceptions import ReleaseVCSError from shutil import rmtree From 508ebd3df37889d4588a2f3e7f2e0147f74ed011 Mon Sep 17 00:00:00 2001 From: Robert Minsk Date: Mon, 25 May 2026 18:01:27 -0700 Subject: [PATCH 10/13] ci(ruff): treat rex a builtin python in tests (#2120) Signed-off-by: Robert Minsk --- ruff.toml | 3 --- src/rez/tests/ruff.toml | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 src/rez/tests/ruff.toml diff --git a/ruff.toml b/ruff.toml index 871f9c2a1..f6022962b 100644 --- a/ruff.toml +++ b/ruff.toml @@ -108,9 +108,6 @@ ignore = [ ] [lint.per-file-ignores] -"src/rez/tests/*.py" = [ - "F821" # Undefined name -] "src/rez/bind/_pymodule.py" = [ "F821" # Undefined name ] diff --git a/src/rez/tests/ruff.toml b/src/rez/tests/ruff.toml new file mode 100644 index 000000000..7531e3c35 --- /dev/null +++ b/src/rez/tests/ruff.toml @@ -0,0 +1,20 @@ +extend = "../../../ruff.toml" + +# Treat rex as builtin +builtins = [ + "alias", + "appendenv", + "command", + "comment", + "defined", + "env", + "error", + "getenv", + "info", + "prependenv", + "setenv", + "shebang", + "source", + "undefined", + "unsetenv", +] From f5525ca94ea5d75c77b6b072e642062245774c58 Mon Sep 17 00:00:00 2001 From: Robert Minsk Date: Mon, 25 May 2026 18:15:36 -0700 Subject: [PATCH 11/13] refactor(ruff): get rid of some undefined names (#2120) Signed-off-by: Robert Minsk --- ruff.toml | 6 ------ src/rez/bind/_pymodule.py | 6 +++--- src/rez/resolver.py | 2 ++ 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/ruff.toml b/ruff.toml index f6022962b..b1208f4e3 100644 --- a/ruff.toml +++ b/ruff.toml @@ -108,15 +108,9 @@ ignore = [ ] [lint.per-file-ignores] -"src/rez/bind/_pymodule.py" = [ - "F821" # Undefined name -] "src/rez/utils/filesystem.py" = [ "F821" # Undefined name ] -"src/rez/resolver.py" = [ - "F821" # Undefined name -] "src/rez/cli/release.py" = [ "F821" # Undefined name ] diff --git a/src/rez/bind/_pymodule.py b/src/rez/bind/_pymodule.py index 74d6c0171..ad0f9dc2b 100644 --- a/src/rez/bind/_pymodule.py +++ b/src/rez/bind/_pymodule.py @@ -21,12 +21,12 @@ def commands() -> None: - env.PYTHONPATH.append('{this.root}/python') + env.PYTHONPATH.append('{this.root}/python') # noqa: F821 def commands_with_bin() -> None: - env.PYTHONPATH.append('{this.root}/python') - env.PATH.append('{this.root}/bin') + env.PYTHONPATH.append('{this.root}/python') # noqa: F821 + env.PATH.append('{this.root}/bin') # noqa: F821 def copy_module(name, destpath): diff --git a/src/rez/resolver.py b/src/rez/resolver.py index 162bdb525..1da2a4137 100644 --- a/src/rez/resolver.py +++ b/src/rez/resolver.py @@ -20,7 +20,9 @@ if TYPE_CHECKING: from rez.package_order import PackageOrderList from rez.resolved_context import ResolvedContext + from rez.utils.resources import ResourceHandle from rez.utils.typing import SupportsWrite + from rez.vendor.pygraph.classes.digraph import digraph class SolverDict(TypedDict): From ff9215d5d29346d936dacdc868b29c33b3c23151 Mon Sep 17 00:00:00 2001 From: Robert Minsk Date: Mon, 25 May 2026 18:28:30 -0700 Subject: [PATCH 12/13] refactor(ruff): suppress ambiguous class name (#2120) Signed-off-by: Robert Minsk --- ruff.toml | 3 --- src/rez/tests/test_formatter.py | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/ruff.toml b/ruff.toml index b1208f4e3..957ffe02c 100644 --- a/ruff.toml +++ b/ruff.toml @@ -114,9 +114,6 @@ ignore = [ "src/rez/cli/release.py" = [ "F821" # Undefined name ] -"src/rez/tests/test_formatter.py" = [ - "E742" # Ambiguous class name: `I` -] "src/rezplugins/release_vcs/git.py" = [ "F821" # Undefined name ] diff --git a/src/rez/tests/test_formatter.py b/src/rez/tests/test_formatter.py index 792ff8f4a..0f2199103 100644 --- a/src/rez/tests/test_formatter.py +++ b/src/rez/tests/test_formatter.py @@ -100,7 +100,7 @@ class H(object): def __format__(self, format_spec) -> str: return 1.0 - class I(datetime.date): + class I(datetime.date): # noqa: E742 def __format__(self, format_spec) -> str: return self.strftime(format_spec) From 170639840ebf6b25f386288abcfdb73e79a9b59c Mon Sep 17 00:00:00 2001 From: Robert Minsk Date: Thu, 25 Jun 2026 18:20:52 -0700 Subject: [PATCH 13/13] ci: do not use ruff on src/support (#2120) Signed-off-by: Robert Minsk --- .github/workflows/ruff.yaml | 2 ++ ruff.toml | 12 +++--------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ruff.yaml b/.github/workflows/ruff.yaml index 5b490af52..b3adbf418 100644 --- a/.github/workflows/ruff.yaml +++ b/.github/workflows/ruff.yaml @@ -13,6 +13,7 @@ on: - '!src/rez/utils/_version.py' - '!src/rez/vendor/**' - '!src/rez/data/**' + - '!src/support/**' push: paths: - '.github/workflows/ruff.yaml' @@ -26,6 +27,7 @@ on: - '!src/rez/utils/_version.py' - '!src/rez/vendor/**' - '!src/rez/data/**' + - '!src/support/**' permissions: contents: read diff --git a/ruff.toml b/ruff.toml index 957ffe02c..134a64f4b 100644 --- a/ruff.toml +++ b/ruff.toml @@ -21,6 +21,7 @@ include = [ extend-exclude = [ "src/rez/vendor", "src/rez/data", + "src/support" ] # Match flake8 linter defaults @@ -108,18 +109,11 @@ ignore = [ ] [lint.per-file-ignores] -"src/rez/utils/filesystem.py" = [ - "F821" # Undefined name -] -"src/rez/cli/release.py" = [ - "F821" # Undefined name -] +# Bug in the following. Uses the git python package, which is not installed, in the +# export # class method. rez-diff calls the method. "src/rezplugins/release_vcs/git.py" = [ "F821" # Undefined name ] -"src/support/package_utils/set_authors.py" = [ - "INP001" # part of an implicit namespace package -] [lint.flake8-annotations] # Allow "Any" for dynamically typed *args and **kwargs arguments