Skip to content

Commit

Permalink
chore: cleanup Ruff a bit (#783)
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii authored Feb 24, 2024
1 parent 1fe4437 commit c248a76
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 28 deletions.
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import os
import sys

try:
import importlib.metadata as metadata
except ImportError:
if sys.version_info >= (3, 8):
from importlib import metadata
else:
import importlib_metadata as metadata

# If extensions (or modules to document with autodoc) are in another directory,
Expand Down
2 changes: 1 addition & 1 deletion nox/_option_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import argparse
import collections
import functools
from argparse import ArgumentError as ArgumentError
from argparse import ArgumentError as ArgumentError # noqa: PLC0414
from argparse import ArgumentParser, Namespace
from collections.abc import Callable, Iterable
from typing import Any
Expand Down
6 changes: 2 additions & 4 deletions nox/_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,8 @@ def _force_venv_backend_merge_func(
raise ValueError(
"You can not use `--no-venv` with a non-none `--force-venv-backend`"
)
else:
return "none"
else:
return command_args.force_venv_backend or noxfile_args.force_venv_backend # type: ignore[no-any-return]
return "none"
return command_args.force_venv_backend or noxfile_args.force_venv_backend # type: ignore[no-any-return]


def _envdir_merge_func(
Expand Down
6 changes: 3 additions & 3 deletions nox/_parametrize.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def update_param_specs(
combined_specs = []
for new_spec in new_specs:
for spec in param_specs:
spec = spec.copy()
spec.update(new_spec)
combined_specs.append(spec)
spec_copy = spec.copy()
spec_copy.update(new_spec)
combined_specs.append(spec_copy)
return combined_specs
2 changes: 1 addition & 1 deletion nox/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from packaging.version import InvalidVersion, Version

if sys.version_info >= (3, 8):
import importlib.metadata as metadata
from importlib import metadata
else:
import importlib_metadata as metadata

Expand Down
13 changes: 6 additions & 7 deletions nox/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ def _get_format(colorlog: bool, add_timestamp: bool) -> str:
if colorlog:
if add_timestamp:
return "%(cyan)s%(name)s > [%(asctime)s] %(log_color)s%(message)s"
else:
return "%(cyan)s%(name)s > %(log_color)s%(message)s"
else:
if add_timestamp:
return "%(name)s > [%(asctime)s] %(message)s"
else:
return "%(name)s > %(message)s"
return "%(cyan)s%(name)s > %(log_color)s%(message)s"

if add_timestamp:
return "%(name)s > [%(asctime)s] %(message)s"

return "%(name)s > %(message)s"


class NoxFormatter(logging.Formatter):
Expand Down
4 changes: 2 additions & 2 deletions nox/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ def conda_install(
raise ValueError("At least one argument required to install().")

if self._runner.global_config.no_install and venv._reused:
return None
return

# Escape args that should be (conda-specific; pip install does not need this)
args = _dblquote_pkg_install_args(args)
Expand Down Expand Up @@ -645,7 +645,7 @@ def install(self, *args: str, **kwargs: Any) -> None:
raise ValueError("At least one argument required to install().")

if self._runner.global_config.no_install and venv._reused:
return None
return

if "silent" not in kwargs:
kwargs["silent"] = True
Expand Down
9 changes: 5 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,21 @@ extend-select = [
"C4", # flake8-comprehensions
"ICN", # flake8-import-conventions
"ISC", # flake8-implicit-str-concat
"PL", # pylint
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"RUF", # Ruff-specific
"SIM", # flake8-simplify
"UP", # pyupgrade
"YTT", # flake8-2020
"EXE", # flake8-executable
]
ignore = [
"ISC001", # Conflicts with formatter
"ISC001", # Conflicts with formatter
"PLR09", # Too many X
"PLR2004", # Magic value used in comparison
]

[tool.ruff]
target-version = "py37"

[tool.isort]
profile = "black"

Expand Down
6 changes: 3 additions & 3 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
import nox.registry
import nox.sessions

try:
import importlib.metadata as metadata
except ImportError:
if sys.version_info >= (3, 8):
from importlib import metadata
else:
import importlib_metadata as metadata


Expand Down

0 comments on commit c248a76

Please sign in to comment.