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

Upgrade linters to the latest version #438

Merged
merged 13 commits into from
Jun 5, 2021
6 changes: 1 addition & 5 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes :)

2 changes: 1 addition & 1 deletion nox/_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions nox/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
1 change: 1 addition & 0 deletions nox/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions nox/popen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion nox/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion nox/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions nox/virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -329,7 +330,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"
Expand Down
10 changes: 5 additions & 5 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ 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==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")
def lint(session):
session.install("flake8==3.7.8", "black==19.3b0", "isort==4.3.21", "mypy==0.720")
session.install("flake8==3.9.2", "black==21.5b2", "isort==5.8.0", "mypy==0.812")
session.run(
"mypy",
"--config-file=",
Expand All @@ -97,8 +97,8 @@ 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("isort", "--check", *files)
session.run("flake8", *files)


@nox.session(python="3.7")
Expand Down
1 change: 1 addition & 0 deletions tests/test__option_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/test__parametrize.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from unittest import mock

import pytest

from nox import _decorators, _parametrize, parametrize, session


Expand Down
1 change: 1 addition & 0 deletions tests/test__version.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from typing import Optional

import pytest

from nox import needs_version
from nox._version import (
InvalidVersionSpecifier,
Expand Down
5 changes: 3 additions & 2 deletions tests/test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -474,7 +475,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")

Expand Down
1 change: 1 addition & 0 deletions tests/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from unittest import mock

import pytest

from nox import logger


Expand Down
3 changes: 2 additions & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion tests/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions tests/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import pytest

from nox import registry


Expand Down
3 changes: 2 additions & 1 deletion tests/test_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions tests/test_tox_to_nox.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import textwrap

import pytest

from nox import tox_to_nox


Expand Down
3 changes: 2 additions & 1 deletion tests/test_virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down