diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4ebf2058..edd1c703 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,14 +4,14 @@ ci: repos: - repo: https://github.com/psf/black - rev: "22.3.0" + rev: "22.6.0" hooks: - id: black args: - "--preview" - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.2.0 + rev: v4.3.0 hooks: - id: check-added-large-files - id: check-case-conflict @@ -31,7 +31,7 @@ repos: args: ["-a", "from __future__ import annotations"] - repo: https://github.com/asottile/pyupgrade - rev: v2.32.0 + rev: v2.37.3 hooks: - id: pyupgrade args: [--py37-plus] @@ -42,28 +42,28 @@ repos: - id: pyproject-fmt - repo: https://github.com/hadialqattan/pycln - rev: v1.3.2 + rev: v2.1.1 hooks: - id: pycln args: [--all] stages: [manual] - repo: https://github.com/asottile/yesqa - rev: v1.3.0 + rev: v1.4.0 hooks: - id: yesqa additional_dependencies: &flake8-dependencies - flake8-bugbear - repo: https://github.com/pycqa/flake8 - rev: 4.0.1 + rev: 5.0.4 hooks: - id: flake8 exclude: docs/conf.py additional_dependencies: *flake8-dependencies - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.950 + rev: v0.971 hooks: - id: mypy files: ^nox/ diff --git a/nox/_option_set.py b/nox/_option_set.py index 26014117..39179d8d 100644 --- a/nox/_option_set.py +++ b/nox/_option_set.py @@ -37,6 +37,8 @@ class OptionGroup: kwargs: Passed through to``ArgumentParser.add_argument_group``. """ + __slots__ = ("name", "args", "kwargs") + def __init__(self, name: str, *args: Any, **kwargs: Any) -> None: self.name = name self.args = args diff --git a/nox/_typing.py b/nox/_typing.py index 2c6a30a8..9820c164 100644 --- a/nox/_typing.py +++ b/nox/_typing.py @@ -22,7 +22,7 @@ from typing import TYPE_CHECKING except ImportError: try: - from typing_extensions import TYPE_CHECKING + from typing import TYPE_CHECKING except ImportError: TYPE_CHECKING = False @@ -30,7 +30,7 @@ from typing import NoReturn except ImportError: try: - from typing_extensions import NoReturn + from typing import NoReturn except ImportError: pass @@ -39,7 +39,7 @@ from typing import ClassVar except ImportError: try: - from typing_extensions import ClassVar + from typing import ClassVar except ImportError: pass diff --git a/nox/_version.py b/nox/_version.py index ccb5bad2..811e57bc 100644 --- a/nox/_version.py +++ b/nox/_version.py @@ -86,7 +86,7 @@ def _check_nox_version_satisfies(needs_version: str) -> None: with contextlib.suppress(InvalidVersion): Version(needs_version) message += f", did you mean '>= {needs_version}'?" - raise InvalidVersionSpecifier(message) + raise InvalidVersionSpecifier(message) from error if not specifiers.contains(version, prereleases=True): raise VersionCheckFailed( diff --git a/nox/manifest.py b/nox/manifest.py index cbd80f64..3e291010 100644 --- a/nox/manifest.py +++ b/nox/manifest.py @@ -233,7 +233,6 @@ def make_session( # If the func has the python attribute set to a list, we'll need # to expand them. if isinstance(func.python, (list, tuple, set)): - for python in func.python: single_func = func.copy() single_func.python = python diff --git a/nox/sessions.py b/nox/sessions.py index 4a66229e..bae30743 100644 --- a/nox/sessions.py +++ b/nox/sessions.py @@ -158,7 +158,8 @@ def env(self) -> dict[str, str]: @property def posargs(self) -> list[str]: - """Any extra arguments from the ``nox`` commandline or :class:`Session.notify`.""" + """Any extra arguments from the ``nox`` commandline or :class:`Session.notify`. + """ return self._runner.posargs @property @@ -203,7 +204,8 @@ def cache_dir(self) -> pathlib.Path: @property def interactive(self) -> bool: - """Returns True if Nox is being run in an interactive session or False otherwise.""" + """Returns True if Nox is being run in an interactive session or False otherwise. + """ return not self._runner.global_config.non_interactive and sys.stdin.isatty() @property @@ -246,7 +248,7 @@ def _run_func( return func(*args, **kwargs) except Exception as e: logger.exception(f"Function {func!r} raised {e!r}.") - raise nox.command.CommandFailed() + raise nox.command.CommandFailed() from e def run( self, *args: str, env: Mapping[str, str] | None = None, **kwargs: Any diff --git a/tests/test__parametrize.py b/tests/test__parametrize.py index 3af4b22a..f21fddd8 100644 --- a/tests/test__parametrize.py +++ b/tests/test__parametrize.py @@ -166,7 +166,6 @@ def f(): def test_generate_calls_simple(): - f = mock.Mock() f.__name__ = "f" f.some_prop = 42 @@ -199,7 +198,6 @@ def test_generate_calls_simple(): def test_generate_calls_multiple_args(): - f = mock.Mock() f.__name__ = "f"