Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable preview lint checks of ruff #3544

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,11 @@ exclude = [
]

[tool.ruff.lint]
# Enable preview rules...
preview = true
# ... but enable them manually for now.
explicit-preview-rules = true

select = [
"F", # pyflakes
"E", # pycodestyle error
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ def test_not_in_repository(
cls,
nested_file: tuple[Path, Path, Path],
root_logger):
top_dir, sub_dir, file = nested_file
_, sub_dir, _ = nested_file

with pytest.raises(GeneralError, match=r"Failed to add path .* to git index."):
git_add(path=sub_dir, logger=root_logger)
Expand All @@ -1023,7 +1023,7 @@ def test_in_repository(
cls,
nested_file: tuple[Path, Path, Path],
root_logger):
top_dir, sub_dir, file = nested_file
top_dir, sub_dir, _ = nested_file
run(ShellScript('git init').to_shell_command(), cwd=top_dir)

git_add(path=sub_dir, logger=root_logger)
Expand Down
5 changes: 2 additions & 3 deletions tmt/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def rendered(self) -> str:
class Path(click.ParamType):
name = 'path'

def convert(
def convert( # noqa: RET503
self,
value: Any,
param: Optional[click.Parameter],
Expand Down Expand Up @@ -100,8 +100,7 @@ def convert(
ctx=ctx,
)

# RET503: ruff does not recognize NoReturn annotation of `self.fail`.
self.fail( # noqa: RET503
self.fail(
f"Field '{param.name}' must be a path-like string, '{type(value).__name__}' found.",
param=param,
ctx=ctx,
Expand Down
12 changes: 2 additions & 10 deletions tmt/steps/provision/mrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,7 @@ def _transform_unsupported(
def _transform_beaker_pool(
constraint: tmt.hardware.TextConstraint, logger: tmt.log.Logger
) -> MrackBaseHWElement:
beaker_operator, actual_value, negate = operator_to_beaker_op(
constraint.operator, constraint.value
)
beaker_operator, actual_value, _ = operator_to_beaker_op(constraint.operator, constraint.value)

return MrackHWBinOp('pool', beaker_operator, actual_value)

Expand Down Expand Up @@ -464,20 +462,14 @@ def _transform_memory(
def _transform_tpm_version(
constraint: tmt.hardware.TextConstraint, logger: tmt.log.Logger
) -> MrackBaseHWElement:
beaker_operator, actual_value, negate = operator_to_beaker_op(
constraint.operator, constraint.value
)
beaker_operator, actual_value, _ = operator_to_beaker_op(constraint.operator, constraint.value)

return MrackHWKeyValue('TPM', beaker_operator, actual_value)


def _transform_virtualization_is_virtualized(
constraint: tmt.hardware.FlagConstraint, logger: tmt.log.Logger
) -> MrackBaseHWElement:
beaker_operator, actual_value, _ = operator_to_beaker_op(
constraint.operator, str(constraint.value)
)

test = (constraint.operator, constraint.value)

if test in [(tmt.hardware.Operator.EQ, True), (tmt.hardware.Operator.NEQ, False)]:
Expand Down
2 changes: 1 addition & 1 deletion tmt/steps/report/reportportal.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ def execute_rp_import(self) -> None:
# The datetime *strings* are in fact sorted here, but finding the minimum will work,
# because the datetime in ISO format is designed to be lexicographically sortable.
launch_time = min(
[r.start_time or self.datetime for r in self.step.plan.execute.results()]
r.start_time or self.datetime for r in self.step.plan.execute.results()
)

# Create launch, suites (if "--suite_per_plan") and tests;
Expand Down