From e6aeaf6a45ded5ee5ad815186698ba979be56196 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 26 Apr 2024 01:40:06 -0400 Subject: [PATCH 1/2] chore: bump pre-commit Signed-off-by: Henry Schreiner --- .pre-commit-config.yaml | 8 ++++---- experiments/parallel.py | 3 +-- plumbum/cli/application.py | 2 +- plumbum/cli/terminal.py | 1 - plumbum/cli/termsize.py | 2 +- plumbum/colorlib/__main__.py | 1 - plumbum/colorlib/factories.py | 1 - plumbum/colorlib/names.py | 1 + plumbum/colorlib/styles.py | 1 - plumbum/colors.py | 1 - plumbum/commands/processes.py | 2 +- pyproject.toml | 2 +- tests/test_remote.py | 8 ++++---- 13 files changed, 14 insertions(+), 19 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4052b10ee..4c28926d0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ ci: repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: "v4.5.0" + rev: "v4.6.0" hooks: - id: check-added-large-files - id: check-case-conflict @@ -20,14 +20,14 @@ repos: - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.1.3" + rev: "v0.4.2" hooks: - id: ruff args: ["--fix", "--show-fixes"] - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy - rev: "v1.6.1" + rev: "v1.10.0" hooks: - id: mypy files: plumbum @@ -35,7 +35,7 @@ repos: additional_dependencies: [typed-ast, types-paramiko, types-setuptools, pytest] - repo: https://github.com/abravalheri/validate-pyproject - rev: "v0.15" + rev: "v0.16" hooks: - id: validate-pyproject diff --git a/experiments/parallel.py b/experiments/parallel.py index 1814d5af6..f4fef22c0 100644 --- a/experiments/parallel.py +++ b/experiments/parallel.py @@ -127,8 +127,7 @@ def path(self, *parts): def __getitem__(self, progname): if not isinstance(progname, str): raise TypeError( - "progname must be a string, not %r" - % ( + "progname must be a string, not {!r}".format( type( progname, ) diff --git a/plumbum/cli/application.py b/plumbum/cli/application.py index 6e7436393..341817fc9 100644 --- a/plumbum/cli/application.py +++ b/plumbum/cli/application.py @@ -549,7 +549,7 @@ def _validate_args(self, swfuncs, tailargs): else sig.return_annotation ) if sys.version_info < (3, 10) and isinstance(annotation, str): - annotation = eval(annotation) # noqa: PGH001 + annotation = eval(annotation) if item == m.varargs: varargs = annotation elif item != "return": diff --git a/plumbum/cli/terminal.py b/plumbum/cli/terminal.py index 6ce41654d..713b70979 100644 --- a/plumbum/cli/terminal.py +++ b/plumbum/cli/terminal.py @@ -3,7 +3,6 @@ -------------------------- """ - import contextlib import os import sys diff --git a/plumbum/cli/termsize.py b/plumbum/cli/termsize.py index 55dae1959..869ae137f 100644 --- a/plumbum/cli/termsize.py +++ b/plumbum/cli/termsize.py @@ -80,7 +80,7 @@ def _ioctl_GWINSZ(fd: int) -> Optional[Tuple[int, int]]: import termios # TODO: Clean this up. Problems could be hidden by the broad except. - return yx.unpack(fcntl.ioctl(fd, termios.TIOCGWINSZ, b"1234")) # type: ignore[return-value] + return yx.unpack(fcntl.ioctl(fd, termios.TIOCGWINSZ, b"1234")) except Exception: return None diff --git a/plumbum/colorlib/__main__.py b/plumbum/colorlib/__main__.py index 47d47b123..ab37c1589 100644 --- a/plumbum/colorlib/__main__.py +++ b/plumbum/colorlib/__main__.py @@ -4,7 +4,6 @@ to recover terminal color. """ - from . import main main() diff --git a/plumbum/colorlib/factories.py b/plumbum/colorlib/factories.py index c34e88194..0f124aa4c 100644 --- a/plumbum/colorlib/factories.py +++ b/plumbum/colorlib/factories.py @@ -2,7 +2,6 @@ Color-related factories. They produce Styles. """ - import functools import operator import sys diff --git a/plumbum/colorlib/names.py b/plumbum/colorlib/names.py index cb3a590b0..80f8ab96a 100644 --- a/plumbum/colorlib/names.py +++ b/plumbum/colorlib/names.py @@ -5,6 +5,7 @@ You can access the index of the colors with names.index(name). You can access the rgb values with ``r=int(html[n][1:3],16)``, etc. """ + from typing import Tuple color_names = """\ diff --git a/plumbum/colorlib/styles.py b/plumbum/colorlib/styles.py index 8278bb2cd..60ca7a336 100644 --- a/plumbum/colorlib/styles.py +++ b/plumbum/colorlib/styles.py @@ -7,7 +7,6 @@ With the ``Style`` class, any color can be directly called or given to a with statement. """ - import contextlib import os import platform diff --git a/plumbum/colors.py b/plumbum/colors.py index 07ec3f033..1815273b6 100644 --- a/plumbum/colors.py +++ b/plumbum/colors.py @@ -4,7 +4,6 @@ all the standard syntax for colors. """ - import atexit import sys diff --git a/plumbum/commands/processes.py b/plumbum/commands/processes.py index 89c276342..7470d8c22 100644 --- a/plumbum/commands/processes.py +++ b/plumbum/commands/processes.py @@ -383,7 +383,7 @@ def iter_lines( if buffer_size is None: buffer_size = DEFAULT_BUFFER_SIZE - buffer_size: int + buffer_size: int # type: ignore[annotation-unchecked] assert mode in (BY_POSITION, BY_TYPE) diff --git a/pyproject.toml b/pyproject.toml index f3edc5706..b7057f5b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,7 +80,7 @@ build.hooks.vcs.version-file = "plumbum/version.py" [tool.mypy] files = ["plumbum"] -python_version = "3.7" +python_version = "3.8" warn_unused_configs = true warn_unused_ignores = true show_error_codes = true diff --git a/tests/test_remote.py b/tests/test_remote.py index 913dc9a16..1f296d7b6 100644 --- a/tests/test_remote.py +++ b/tests/test_remote.py @@ -636,11 +636,11 @@ def test_encoding(self): with self._connect() as rem: unicode_half = b"\xc2\xbd".decode("utf8") - ret = rem["bash"]("-c", 'echo -e "\xC2\xBD"') - assert ret == "%s\n" % unicode_half + ret = rem["bash"]("-c", 'echo -e "\xc2\xbd"') + assert ret == f"{unicode_half}\n" - ret = list(rem["bash"]["-c", 'echo -e "\xC2\xBD"'].popen()) - assert ret == [["%s\n" % unicode_half, None]] + ret = list(rem["bash"]["-c", 'echo -e "\xc2\xbd"'].popen()) + assert ret == [[f"{unicode_half}\n", None]] def test_path_open_remote_write_local_read(self): with self._connect() as rem: From 5085d23231fa3140a5df6a60ed09c6a10f95c3f2 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 26 Apr 2024 01:45:26 -0400 Subject: [PATCH 2/2] ci: macos-latest now points at macos-14, which is ARM Signed-off-by: Henry Schreiner --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c88e3f34..c5d47939f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: fail-fast: false matrix: python-version: ["3.6", "3.8", "3.11", "3.12"] - os: [ubuntu-latest, windows-latest, macos-latest] + os: [ubuntu-latest, windows-latest, macos-13] include: - python-version: 'pypy-3.8' os: ubuntu-latest