Skip to content

Commit d4900b0

Browse files
authored
Merge pull request #173 from consideRatio/pr/add-pyupgrade-and-isort
pre-commit: add pyupgrade and isort (replaces reorder-python-imports)
2 parents 204fa2b + 9432633 commit d4900b0

File tree

5 files changed

+41
-31
lines changed

5 files changed

+41
-31
lines changed

.pre-commit-config.yaml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,39 @@
99
# - Register git hooks: pre-commit install --install-hooks
1010
#
1111
repos:
12+
# Autoformat: Python code, syntax patterns are modernized
13+
- repo: https://github.com/asottile/pyupgrade
14+
rev: v2.37.3
15+
hooks:
16+
- id: pyupgrade
17+
args:
18+
- --py37-plus
19+
1220
# Autoformat: Python code
1321
- repo: https://github.com/psf/black
1422
rev: 22.6.0
1523
hooks:
1624
- id: black
17-
args: [--target-version=py36]
25+
args:
26+
- --target-version=py37
27+
- --target-version=py38
28+
- --target-version=py39
29+
- --target-version=py310
30+
31+
# Autoformat: Python code
32+
- repo: https://github.com/pycqa/isort
33+
rev: 5.10.1
34+
hooks:
35+
- id: isort
36+
args:
37+
- --profile=black
1838

1939
# Autoformat: markdown, yaml
2040
- repo: https://github.com/pre-commit/mirrors-prettier
2141
rev: v2.7.1
2242
hooks:
2343
- id: prettier
2444

25-
# Autoformat: https://github.com/asottile/reorder_python_imports
26-
- repo: https://github.com/asottile/reorder_python_imports
27-
rev: v3.8.2
28-
hooks:
29-
- id: reorder-python-imports
30-
3145
# Misc...
3246
- repo: https://github.com/pre-commit/pre-commit-hooks
3347
rev: v4.3.0

chartpress.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
import sys
1414
from collections.abc import MutableMapping
1515
from enum import Enum
16-
from functools import lru_cache
17-
from functools import partial
16+
from functools import lru_cache, partial
1817
from tempfile import TemporaryDirectory
1918

2019
import docker

tests/test_chartpress.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import json
22
import sys
3-
from subprocess import PIPE
4-
from subprocess import run
5-
from urllib.request import Request
6-
from urllib.request import urlopen
3+
from subprocess import PIPE, run
4+
from urllib.request import Request, urlopen
75
from uuid import uuid4
86

97
import pytest
@@ -13,8 +11,7 @@ def test_list_images(git_repo):
1311
p = run(
1412
[sys.executable, "-m", "chartpress", "--list-images"],
1513
check=True,
16-
stdout=PIPE,
17-
stderr=PIPE,
14+
capture_output=True,
1815
)
1916
stdout = p.stdout.decode("utf8").strip()
2017
# echo stdout/stderr for debugging
@@ -30,8 +27,7 @@ def test_list_images(git_repo):
3027
p = run(
3128
["git", "status", "--porcelain"],
3229
check=True,
33-
stdout=PIPE,
34-
stderr=PIPE,
30+
capture_output=True,
3531
)
3632
assert not p.stdout, "--list-images should not make changes!"
3733

@@ -86,8 +82,7 @@ def test_buildx(git_repo):
8682
tag,
8783
],
8884
check=True,
89-
stdout=PIPE,
90-
stderr=PIPE,
85+
capture_output=True,
9186
)
9287
stdout = p.stdout.decode("utf8").strip()
9388
stderr = p.stderr.decode("utf8").strip()

tests/test_helpers.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import pytest
22
from ruamel.yaml import YAML
33

4-
from chartpress import _check_call
5-
from chartpress import _get_git_remote_url
6-
from chartpress import _get_identifier_from_parts
7-
from chartpress import _get_image_build_args
8-
from chartpress import _get_image_extra_build_command_options
9-
from chartpress import _get_latest_commit_tagged_or_modifying_paths
10-
from chartpress import _image_needs_pushing
11-
from chartpress import Builder
12-
from chartpress import GITHUB_ACTOR_KEY
13-
from chartpress import GITHUB_TOKEN_KEY
4+
from chartpress import (
5+
GITHUB_ACTOR_KEY,
6+
GITHUB_TOKEN_KEY,
7+
Builder,
8+
_check_call,
9+
_get_git_remote_url,
10+
_get_identifier_from_parts,
11+
_get_image_build_args,
12+
_get_image_extra_build_command_options,
13+
_get_latest_commit_tagged_or_modifying_paths,
14+
_image_needs_pushing,
15+
)
1416

1517
# use safe roundtrip yaml loader
1618
yaml = YAML(typ="rt")

tests/test_repo_interactions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def test_chartpress_run(git_repo, capfd):
117117
git_repo.git.checkout("gh-pages")
118118

119119
# verify result of --publish-chart
120-
with open("index.yaml", "r") as f:
120+
with open("index.yaml") as f:
121121
index_yaml = f.read()
122122
print(index_yaml)
123123
assert f"version: 1.2.1" in index_yaml
@@ -180,7 +180,7 @@ def test_chartpress_run(git_repo, capfd):
180180
git_repo.git.checkout("gh-pages")
181181

182182
# verify result of --publish-chart
183-
with open("index.yaml", "r") as f:
183+
with open("index.yaml") as f:
184184
index_yaml = f.read()
185185
print("index_yaml follows:")
186186
print(index_yaml)

0 commit comments

Comments
 (0)