Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ruff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
- '!src/rez/utils/_version.py'
- '!src/rez/vendor/**'
- '!src/rez/data/**'
- '!src/support/**'
push:
paths:
- '.github/workflows/ruff.yaml'
Expand All @@ -26,6 +27,7 @@ on:
- '!src/rez/utils/_version.py'
- '!src/rez/vendor/**'
- '!src/rez/data/**'
- '!src/support/**'

permissions:
contents: read
Expand Down
3 changes: 1 addition & 2 deletions install.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import venv
except ImportError:
USE_VIRTUALENV = True
import virtualenv


source_path = os.path.dirname(os.path.realpath(__file__))
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions release-rez.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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)
Expand Down
53 changes: 3 additions & 50 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ include = [
extend-exclude = [
"src/rez/vendor",
"src/rez/data",
"src/support"
]

# Match flake8 linter defaults
Expand Down Expand Up @@ -108,59 +109,11 @@ ignore = [
]

[lint.per-file-ignores]
"__init__.py" = [
"D104" # undocumented-public-package
]
"src/rez/tests/*.py" = [
"F821" # Undefined name
]
"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/_main.py" = [
"ISC002" # Implicitly concatenated string literals over multiple lines
]
"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`
]
"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`
]
# 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
]
"./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
]
"./setup.py" = [
"E402" # Module level import not at top of file
]

[lint.flake8-annotations]
# Allow "Any" for dynamically typed *args and **kwargs arguments
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down
6 changes: 3 additions & 3 deletions src/rez/bind/_pymodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
12 changes: 6 additions & 6 deletions src/rez/cli/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ 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
Expand Down
2 changes: 1 addition & 1 deletion src/rez/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 9 additions & 13 deletions src/rez/package_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]:
"""
Expand Down Expand Up @@ -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]:
"""
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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]:
"""
Expand Down Expand Up @@ -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
)
Expand Down
2 changes: 2 additions & 0 deletions src/rez/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
20 changes: 20 additions & 0 deletions src/rez/tests/ruff.toml
Original file line number Diff line number Diff line change
@@ -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",
]
2 changes: 1 addition & 1 deletion src/rez/tests/test_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion src/rezgui/objects/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 0 additions & 1 deletion src/rezgui/widgets/ContextToolsWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 1 addition & 2 deletions src/rezgui/widgets/TimestampWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/rezplugins/release_vcs/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading