From abd46f67869f8f9b0bb04f7382b923a4a9c8ebe9 Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Thu, 3 Jun 2021 18:26:56 +0200 Subject: [PATCH 01/13] Bump black from 19.3b0 to 21.5b2 --- noxfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/noxfile.py b/noxfile.py index 67d13bfc..74fe979d 100644 --- a/noxfile.py +++ b/noxfile.py @@ -78,7 +78,7 @@ def cover(session): @nox.session(python="3.8") def blacken(session): """Run black code formatter.""" - session.install("black==19.3b0", "isort==4.3.21") + session.install("black==21.5b2", "isort==4.3.21") files = ["nox", "tests", "noxfile.py", "setup.py"] session.run("black", *files) session.run("isort", "--recursive", *files) @@ -86,7 +86,7 @@ def blacken(session): @nox.session(python="3.8") def lint(session): - session.install("flake8==3.7.8", "black==19.3b0", "isort==4.3.21", "mypy==0.720") + session.install("flake8==3.7.8", "black==21.5b2", "isort==4.3.21", "mypy==0.720") session.run( "mypy", "--config-file=", From e89fcb74305f920371f5a35a0c240b98b4f6bbb8 Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Thu, 3 Jun 2021 18:27:57 +0200 Subject: [PATCH 02/13] Reformat with Black --- tests/test_command.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_command.py b/tests/test_command.py index fec272b8..4e87bf49 100644 --- a/tests/test_command.py +++ b/tests/test_command.py @@ -474,7 +474,7 @@ def test_output_decoding_utf8_only_fail(monkeypatch: pytest.MonkeyPatch) -> None def test_output_decoding_utf8_fail_cp1252_success( - monkeypatch: pytest.MonkeyPatch + monkeypatch: pytest.MonkeyPatch, ) -> None: monkeypatch.setattr(nox.popen.locale, "getpreferredencoding", lambda: "cp1252") From 41751dcac0dc31a50ac6c28ee2165ed657b6b033 Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Thu, 3 Jun 2021 18:39:02 +0200 Subject: [PATCH 03/13] Bump flake8 from 3.7.8 to 3.9.2 --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 74fe979d..5e8af7db 100644 --- a/noxfile.py +++ b/noxfile.py @@ -86,7 +86,7 @@ def blacken(session): @nox.session(python="3.8") def lint(session): - session.install("flake8==3.7.8", "black==21.5b2", "isort==4.3.21", "mypy==0.720") + session.install("flake8==3.9.2", "black==21.5b2", "isort==4.3.21", "mypy==0.720") session.run( "mypy", "--config-file=", From 76b61ff15b7ee2515544778e941f3f13d26780bb Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Thu, 3 Jun 2021 18:40:16 +0200 Subject: [PATCH 04/13] Fix F541 (f-string is missing placeholders) --- nox/virtualenv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nox/virtualenv.py b/nox/virtualenv.py index f8ff176c..1988bae3 100644 --- a/nox/virtualenv.py +++ b/nox/virtualenv.py @@ -329,7 +329,7 @@ def _check_reused_environment_type(self) -> bool: # virtualenv < 20.0 does not create pyvenv.cfg old_env = "virtualenv" else: - pattern = re.compile(f"virtualenv[ \t]*=") + pattern = re.compile("virtualenv[ \t]*=") with open(path) as fp: old_env = ( "virtualenv" if any(pattern.match(line) for line in fp) else "venv" From d89499c790650e5b94c5bdc5c3271e39337eee23 Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Thu, 3 Jun 2021 18:40:57 +0200 Subject: [PATCH 05/13] Remove duplicate flake8 argument in lint session --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 5e8af7db..76fa1bae 100644 --- a/noxfile.py +++ b/noxfile.py @@ -98,7 +98,7 @@ def lint(session): files = ["nox", "tests", "noxfile.py", "setup.py"] session.run("black", "--check", *files) session.run("isort", "--check", "--recursive", *files) - session.run("flake8", "nox", *files) + session.run("flake8", *files) @nox.session(python="3.7") From acd1ef78d1e1a1df15914b9075f6ec0a557ab92c Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Thu, 3 Jun 2021 18:42:30 +0200 Subject: [PATCH 06/13] Bump isort from 4.3.21 to 5.8.0 --- noxfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/noxfile.py b/noxfile.py index 76fa1bae..4fae4c41 100644 --- a/noxfile.py +++ b/noxfile.py @@ -78,7 +78,7 @@ def cover(session): @nox.session(python="3.8") def blacken(session): """Run black code formatter.""" - session.install("black==21.5b2", "isort==4.3.21") + session.install("black==21.5b2", "isort==5.8.0") files = ["nox", "tests", "noxfile.py", "setup.py"] session.run("black", *files) session.run("isort", "--recursive", *files) @@ -86,7 +86,7 @@ def blacken(session): @nox.session(python="3.8") def lint(session): - session.install("flake8==3.9.2", "black==21.5b2", "isort==4.3.21", "mypy==0.720") + session.install("flake8==3.9.2", "black==21.5b2", "isort==5.8.0", "mypy==0.720") session.run( "mypy", "--config-file=", From ed4630bccfac0dec0f2557c474700d9a42470b78 Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Thu, 3 Jun 2021 18:44:35 +0200 Subject: [PATCH 07/13] Reorder imports using isort --- nox/command.py | 1 + nox/sessions.py | 3 ++- nox/tasks.py | 3 ++- nox/virtualenv.py | 3 ++- tests/test__option_set.py | 1 + tests/test__parametrize.py | 1 + tests/test__version.py | 1 + tests/test_command.py | 3 ++- tests/test_logger.py | 1 + tests/test_main.py | 3 ++- tests/test_manifest.py | 3 ++- tests/test_registry.py | 1 + tests/test_sessions.py | 3 ++- tests/test_tasks.py | 3 ++- tests/test_tox_to_nox.py | 1 + tests/test_virtualenv.py | 3 ++- 16 files changed, 25 insertions(+), 9 deletions(-) diff --git a/nox/command.py b/nox/command.py index a9a14a82..8d915054 100644 --- a/nox/command.py +++ b/nox/command.py @@ -17,6 +17,7 @@ from typing import Any, Iterable, List, Optional, Sequence, Union import py + from nox.logger import logger from nox.popen import popen diff --git a/nox/sessions.py b/nox/sessions.py index 6ed894a6..31a28e75 100644 --- a/nox/sessions.py +++ b/nox/sessions.py @@ -32,8 +32,9 @@ Union, ) -import nox.command import py + +import nox.command from nox import _typing from nox._decorators import Func from nox.logger import logger diff --git a/nox/tasks.py b/nox/tasks.py index c8d99b0b..c23b118d 100644 --- a/nox/tasks.py +++ b/nox/tasks.py @@ -20,8 +20,9 @@ from argparse import Namespace from typing import List, Union -import nox from colorlog.escape_codes import parse_colors + +import nox from nox import _options, registry from nox._version import InvalidVersionSpecifier, VersionCheckFailed, check_nox_version from nox.logger import logger diff --git a/nox/virtualenv.py b/nox/virtualenv.py index 1988bae3..ab015268 100644 --- a/nox/virtualenv.py +++ b/nox/virtualenv.py @@ -20,8 +20,9 @@ from socket import gethostbyname from typing import Any, List, Mapping, Optional, Tuple, Union -import nox.command import py + +import nox.command from nox.logger import logger from . import _typing diff --git a/tests/test__option_set.py b/tests/test__option_set.py index 3ad8b593..ae238f5e 100644 --- a/tests/test__option_set.py +++ b/tests/test__option_set.py @@ -13,6 +13,7 @@ # limitations under the License. import pytest + from nox import _option_set, _options # The vast majority of _option_set is tested by test_main, but the test helper diff --git a/tests/test__parametrize.py b/tests/test__parametrize.py index 79fc2e5d..e581380b 100644 --- a/tests/test__parametrize.py +++ b/tests/test__parametrize.py @@ -15,6 +15,7 @@ from unittest import mock import pytest + from nox import _decorators, _parametrize, parametrize, session diff --git a/tests/test__version.py b/tests/test__version.py index 2606952c..b4497d02 100644 --- a/tests/test__version.py +++ b/tests/test__version.py @@ -17,6 +17,7 @@ from typing import Optional import pytest + from nox import needs_version from nox._version import ( InvalidVersionSpecifier, diff --git a/tests/test_command.py b/tests/test_command.py index 4e87bf49..db49a874 100644 --- a/tests/test_command.py +++ b/tests/test_command.py @@ -23,9 +23,10 @@ from textwrap import dedent from unittest import mock +import pytest + import nox.command import nox.popen -import pytest PYTHON = sys.executable diff --git a/tests/test_logger.py b/tests/test_logger.py index 50563bd5..eef9dcf3 100644 --- a/tests/test_logger.py +++ b/tests/test_logger.py @@ -16,6 +16,7 @@ from unittest import mock import pytest + from nox import logger diff --git a/tests/test_main.py b/tests/test_main.py index 9f41ac5d..15f7b506 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -18,12 +18,13 @@ from pathlib import Path from unittest import mock +import pytest + import nox import nox.__main__ import nox._options import nox.registry import nox.sessions -import pytest try: import importlib.metadata as metadata diff --git a/tests/test_manifest.py b/tests/test_manifest.py index 9fc0578e..e807619e 100644 --- a/tests/test_manifest.py +++ b/tests/test_manifest.py @@ -15,8 +15,9 @@ import collections from unittest import mock -import nox import pytest + +import nox from nox._decorators import Func from nox.manifest import ( WARN_PYTHONS_IGNORED, diff --git a/tests/test_registry.py b/tests/test_registry.py index 652633e1..3c36f9a1 100644 --- a/tests/test_registry.py +++ b/tests/test_registry.py @@ -13,6 +13,7 @@ # limitations under the License. import pytest + from nox import registry diff --git a/tests/test_sessions.py b/tests/test_sessions.py index 93b9b155..3573b45e 100644 --- a/tests/test_sessions.py +++ b/tests/test_sessions.py @@ -21,12 +21,13 @@ from pathlib import Path from unittest import mock +import pytest + import nox.command import nox.manifest import nox.registry import nox.sessions import nox.virtualenv -import pytest from nox import _options from nox.logger import logger diff --git a/tests/test_tasks.py b/tests/test_tasks.py index 65f3112d..967f605e 100644 --- a/tests/test_tasks.py +++ b/tests/test_tasks.py @@ -21,8 +21,9 @@ from textwrap import dedent from unittest import mock -import nox import pytest + +import nox from nox import _options, sessions, tasks from nox.manifest import WARN_PYTHONS_IGNORED, Manifest diff --git a/tests/test_tox_to_nox.py b/tests/test_tox_to_nox.py index 1e5ff7a0..57ec2bf7 100644 --- a/tests/test_tox_to_nox.py +++ b/tests/test_tox_to_nox.py @@ -16,6 +16,7 @@ import textwrap import pytest + from nox import tox_to_nox diff --git a/tests/test_virtualenv.py b/tests/test_virtualenv.py index 1ff8b436..ac0fa598 100644 --- a/tests/test_virtualenv.py +++ b/tests/test_virtualenv.py @@ -18,10 +18,11 @@ from textwrap import dedent from unittest import mock -import nox.virtualenv import py import pytest +import nox.virtualenv + IS_WINDOWS = nox.virtualenv._SYSTEM == "Windows" HAS_CONDA = shutil.which("conda") is not None RAISE_ERROR = "RAISE_ERROR" From 3a514cf981ace453b4176c064d21427d15bda754 Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Thu, 3 Jun 2021 18:45:57 +0200 Subject: [PATCH 08/13] Simplify isort configuration using black profile --- .isort.cfg | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.isort.cfg b/.isort.cfg index ba2778dc..b9fb3f3e 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -1,6 +1,2 @@ [settings] -multi_line_output=3 -include_trailing_comma=True -force_grid_wrap=0 -use_parentheses=True -line_length=88 +profile=black From e01c4e7078ce9c24cc8d3a6a0b8b531bc84cc045 Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Thu, 3 Jun 2021 18:46:57 +0200 Subject: [PATCH 09/13] Remove obsolete command-line option for isort --- noxfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/noxfile.py b/noxfile.py index 4fae4c41..3b9af584 100644 --- a/noxfile.py +++ b/noxfile.py @@ -81,7 +81,7 @@ def blacken(session): session.install("black==21.5b2", "isort==5.8.0") files = ["nox", "tests", "noxfile.py", "setup.py"] session.run("black", *files) - session.run("isort", "--recursive", *files) + session.run("isort", *files) @nox.session(python="3.8") @@ -97,7 +97,7 @@ def lint(session): ) files = ["nox", "tests", "noxfile.py", "setup.py"] session.run("black", "--check", *files) - session.run("isort", "--check", "--recursive", *files) + session.run("isort", "--check", *files) session.run("flake8", *files) From a0f8df83f15e4f166775350190542e0aaf9147ad Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Thu, 3 Jun 2021 20:07:44 +0200 Subject: [PATCH 10/13] Bump mypy from 0.720 to 0.812 --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 3b9af584..9e247bb2 100644 --- a/noxfile.py +++ b/noxfile.py @@ -86,7 +86,7 @@ def blacken(session): @nox.session(python="3.8") def lint(session): - session.install("flake8==3.9.2", "black==21.5b2", "isort==5.8.0", "mypy==0.720") + session.install("flake8==3.9.2", "black==21.5b2", "isort==5.8.0", "mypy==0.812") session.run( "mypy", "--config-file=", From c0aeea91a46e3d33994434cc4ff9df3718fa94b5 Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Thu, 3 Jun 2021 20:09:19 +0200 Subject: [PATCH 11/13] Avoid mypy warning due to incompatible types in assignment nox/popen.py:77: error: Incompatible types in assignment (expression has type "Optional[bytes]", variable has type "bytes") --- nox/popen.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nox/popen.py b/nox/popen.py index 8e981e1b..9bd1c115 100644 --- a/nox/popen.py +++ b/nox/popen.py @@ -16,10 +16,10 @@ import locale import subprocess import sys -from typing import IO, Mapping, Optional, Sequence, Tuple, Union +from typing import IO, Mapping, Sequence, Tuple, Union -def shutdown_process(proc: subprocess.Popen) -> Tuple[Optional[bytes], Optional[bytes]]: +def shutdown_process(proc: subprocess.Popen) -> Tuple[bytes, bytes]: """Gracefully shutdown a child process.""" with contextlib.suppress(subprocess.TimeoutExpired): From 58c333589a3b6c5d09ca7c6ac641df388f55a1be Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Thu, 3 Jun 2021 20:11:22 +0200 Subject: [PATCH 12/13] Avoid mypy warning about redefining an import nox/_version.py:26: error: Name 'metadata' already defined (by an import) --- nox/_version.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nox/_version.py b/nox/_version.py index 296f2e67..740b7fd3 100644 --- a/nox/_version.py +++ b/nox/_version.py @@ -20,9 +20,9 @@ from packaging.specifiers import InvalidSpecifier, SpecifierSet from packaging.version import InvalidVersion, Version -try: +if sys.version_info >= (3, 8): # pragma: no cover import importlib.metadata as metadata -except ImportError: # pragma: no cover +else: # pragma: no cover import importlib_metadata as metadata From 69072265f314344bf3f215ea39818c6bbd3502a3 Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Thu, 3 Jun 2021 20:53:29 +0200 Subject: [PATCH 13/13] Avoid mypy warning about unused `type: ignore` comment --- nox/_decorators.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nox/_decorators.py b/nox/_decorators.py index b04e48ab..153e331b 100644 --- a/nox/_decorators.py +++ b/nox/_decorators.py @@ -27,7 +27,7 @@ def _copy_func(src: Callable, name: str = None) -> Callable: closure=src.__closure__, # type: ignore ) dst.__dict__.update(copy.deepcopy(src.__dict__)) - dst = functools.update_wrapper(dst, src) # type: ignore + dst = functools.update_wrapper(dst, src) dst.__kwdefaults__ = src.__kwdefaults__ # type: ignore return dst