Skip to content

Commit

Permalink
chore: bump pre-commit (#662)
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii authored Nov 1, 2023
1 parent 40fcd27 commit 668d98a
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 42 deletions.
15 changes: 8 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ci:
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.4.0"
rev: "v4.5.0"
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -20,33 +20,34 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/psf/black-pre-commit-mirror
rev: "23.7.0"
rev: "23.10.1"
hooks:
- id: black

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.0.275"
rev: "v0.1.3"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.3.0"
rev: "v1.6.1"
hooks:
- id: mypy
files: plumbum
args: []
additional_dependencies: [typed-ast, types-paramiko, types-setuptools]
additional_dependencies: [typed-ast, types-paramiko, types-setuptools, pytest]

- repo: https://github.com/abravalheri/validate-pyproject
rev: "v0.13"
rev: "v0.15"
hooks:
- id: validate-pyproject

- repo: https://github.com/codespell-project/codespell
rev: "v2.2.4"
rev: "v2.2.6"
hooks:
- id: codespell
args: ["-w"]

- repo: https://github.com/pre-commit/pygrep-hooks
rev: "v1.10.0"
Expand Down
2 changes: 1 addition & 1 deletion conda.recipe/README.mkd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Building instructions


Change to the `conda.recipies` directory. Run
Change to the `conda.recipes` directory. Run
```bash
$ conda install conda-build
```
Expand Down
2 changes: 1 addition & 1 deletion experiments/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def __exit__(self, t, v, tb):
self.close()

def __del__(self):
try: # noqa: 167
try: # noqa: SIM105
self.close()
except Exception:
pass
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def pylint(session):
Run pylint.
"""

session.install(".", "paramiko", "ipython", "pylint~=2.17.4")
session.install(".", "paramiko", "ipython", "pylint~=3.0.2")
session.run("pylint", "plumbum", *session.posargs)


Expand Down
2 changes: 1 addition & 1 deletion plumbum/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
# ===================================================================================================


if sys.version_info < (3, 7):
if sys.version_info < (3, 7): # noqa: UP036
from types import ModuleType
from typing import List

Expand Down
2 changes: 1 addition & 1 deletion plumbum/_testtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import platform
import sys

import pytest # type: ignore[import]
import pytest

skip_without_chown = pytest.mark.skipif(
not hasattr(os, "chown"), reason="os.chown not supported"
Expand Down
4 changes: 2 additions & 2 deletions plumbum/commands/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class ProcessExecutionError(OSError):

def __init__(self, argv, retcode, stdout, stderr, message=None, *, host=None):
# we can't use 'super' here since OSError only keeps the first 2 args,
# which leads to failuring in loading this object from a pickle.dumps.
# which leads to failing in loading this object from a pickle.dumps.
# pylint: disable-next=non-parent-init-called
Exception.__init__(self, argv, retcode, stdout, stderr)

Expand Down Expand Up @@ -341,7 +341,7 @@ def iter_lines(
:param buffer_size: Maximum number of lines to keep in the stdout/stderr buffers, in case of a ProcessExecutionError.
Default is ``None``, which defaults to DEFAULT_BUFFER_SIZE (which is infinite by default).
``0`` will disable bufferring completely.
``0`` will disable buffering completely.
:param mode: Controls what the generator yields. Defaults to DEFAULT_ITER_LINES_MODE (which is BY_POSITION by default)
- BY_POSITION (default): yields ``(out, err)`` line tuples, where either item may be ``None``
Expand Down
2 changes: 2 additions & 0 deletions plumbum/machines/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,10 @@ def _popen(
kwargs["start_new_session"] = True

if IS_WIN32 and "startupinfo" not in kwargs and stdin not in (sys.stdin, None):
# pylint: disable-next=used-before-assignment
subsystem = get_pe_subsystem(str(executable))

# pylint: disable-next=used-before-assignment
if subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI:
# don't open a new console
sui = subprocess.STARTUPINFO()
Expand Down
8 changes: 3 additions & 5 deletions plumbum/path/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __truediv__(self: _PathImpl, other: typing.Any) -> _PathImpl:
return self.join(other)

def __getitem__(self, key):
if type(key) == str or isinstance(key, Path):
if type(key) == str or isinstance(key, Path): # noqa: E721
return self / key
return str(self)[key]

Expand Down Expand Up @@ -419,10 +419,8 @@ def _glob(pattern, fn):
if isinstance(pattern, str):
return fn(pattern)

results = []
for single_pattern in pattern:
results.extend(fn(single_pattern))
return sorted(list(set(results)))
results = {value for single_pattern in pattern for value in fn(single_pattern)}
return sorted(results)

def resolve(self, strict=False): # noqa: ARG002
"""Added to allow pathlib like syntax. Does nothing since
Expand Down
2 changes: 1 addition & 1 deletion plumbum/path/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def mkdir(self, mode=0o777, parents=True, exist_ok=True):
raise

def open(self, mode="r", encoding=None):
return open(
return open( # noqa: SIM115
str(self),
mode,
encoding=encoding,
Expand Down
21 changes: 10 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ build.hooks.vcs.version-file = "plumbum/version.py"

[tool.mypy]
files = ["plumbum"]
python_version = "3.6"
python_version = "3.7"
warn_unused_configs = true
warn_unused_ignores = true
show_error_codes = true
Expand All @@ -105,7 +105,7 @@ ignore_missing_imports = true

[tool.pytest.ini_options]
minversion = "6.0"
addopts = ["-ra", "--cov-config=setup.cfg", "--strict-markers", "--strict-config"]
addopts = ["-ra", "--showlocals", "--cov-config=setup.cfg", "--strict-markers", "--strict-config"]
norecursedirs = ["examples", "experiments"]
filterwarnings = [
"always"
Expand Down Expand Up @@ -167,9 +167,12 @@ messages_control.disable = [
]

[tool.ruff]
select = [
"E", "F", "W", # flake8
"B", "B904", # flake8-bugbear
target-version = "py37"
exclude = ["docs/conf.py"]

[tool.ruff.lint]
extend-select = [
"B", # flake8-bugbear
"I", # isort
"ARG", # flake8-unused-arguments
"C4", # flake8-comprehensions
Expand All @@ -185,21 +188,17 @@ select = [
"T20", # flake8-print
"UP", # pyupgrade
"YTT", # flake8-2020

]
extend-ignore = [
ignore = [
"E501",
"PLR",
"PT004",
"PT011", # TODO: add match parameter
"RUF012", # ClassVar required if mutable
]
target-version = "py37"
exclude = ["docs/conf.py"]
mccabe.max-complexity = 50
flake8-unused-arguments.ignore-variadic-names = true

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"examples/*" = ["T20"]
"experiments/*" = ["T20"]
"tests/*" = ["T20"]
Expand Down
8 changes: 3 additions & 5 deletions tests/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,16 +902,14 @@ def test_atomic_counter(self):
num_of_procs = 20
num_of_increments = 20

code = """from plumbum.fs.atomic import AtomicCounterFile
code = f"""from plumbum.fs.atomic import AtomicCounterFile
import time
time.sleep(0.2)
afc = AtomicCounterFile.open("counter")
for _ in range({}):
for _ in range({num_of_increments}):
print(afc.next())
time.sleep(0.1)
""".format(
num_of_increments,
)
"""

procs = []
for _ in range(num_of_procs):
Expand Down
10 changes: 4 additions & 6 deletions tests/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,14 +528,12 @@ def test_reverse_tunnel(self, dynamic_dport):
assert_is_port(tun.dport)
assert tun.reverse

remote_send_af_inet = """import socket
remote_send_af_inet = f"""import socket
s = socket.socket()
s.connect(("localhost", {}))
s.send("{}".encode("ascii"))
s.connect(("localhost", {tun.dport}))
s.send("{message}".encode("ascii"))
s.close()
""".format(
tun.dport, message
)
"""
(rem.python["-u"] << remote_send_af_inet).popen()
tunnel_server.join(timeout=1)
assert queue.get() == message
Expand Down

0 comments on commit 668d98a

Please sign in to comment.