Skip to content
This repository was archived by the owner on Dec 3, 2022. It is now read-only.

Commit e25a5ef

Browse files
authored
Fix deps (#91)
* update dependencies * add `cfg-lint --force` command * update linting rules * fix lint/sort * update isort usage
1 parent 744ebd1 commit e25a5ef

File tree

7 files changed

+652
-449
lines changed

7 files changed

+652
-449
lines changed

blue_chip/__main__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
~~~~~~~~~~~~~~~~~~~~~
44
"""
55
import pkg_resources
6-
from invoke import Collection, Program # pylint: disable=import-error
6+
from invoke import Collection, Program
77

88
import blue_chip.tasks
99

@@ -26,7 +26,6 @@ def get_version(pkg_name=PACKAGE_NAME):
2626

2727
PKG_VERSION = get_version()
2828

29-
# pylint: disable=invalid-name
3029
program = Program(
3130
namespace=Collection.from_module(blue_chip.tasks),
3231
name=PACKAGE_NAME,

blue_chip/config/data.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
- line-too-long
1212
# black conflict
1313
- bad-continuation
14-
options:
15-
logging-format-style: "fstr"
1614
1715
pep8:
1816
options:
@@ -28,7 +26,7 @@
2826
# Multi-line docstring summary should start at the first line
2927
- D212
3028
""",
31-
"bc_audit.yaml": f"""strictness: veryhigh
29+
"bc_audit.yaml": """strictness: veryhigh
3230
test-warnings: false
3331
doc-warnings: true
3432
@@ -53,7 +51,7 @@
5351
disable:
5452
- PYR18
5553
""",
56-
"bc_default.yaml": f"""strictness: veryhigh
54+
"bc_default.yaml": """strictness: veryhigh
5755
test-warnings: false
5856
doc-warnings: true
5957
@@ -85,7 +83,7 @@
8583
pep257:
8684
run: True
8785
""",
88-
"bc_tests.yaml": f"""inherits:
86+
"bc_tests.yaml": """inherits:
8987
- bc_default.yaml
9088
9189
strictness: high

blue_chip/tasks/formatting.py

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,31 @@
1313

1414
@task(
1515
help={
16-
"line-length": "How many characters per line to allow. [default: {}]".format(
17-
constants.LINE_LENGTH
18-
),
16+
"line-length": "How many characters per line to allow."
17+
f" [default: { constants.LINE_LENGTH}]",
1918
"targets": "Paths/directories to format. [default: . ]",
2019
},
2120
)
22-
def sort(ctx, line_length=constants.LINE_LENGTH, targets="."):
21+
def sort(ctx, line_length=constants.LINE_LENGTH, targets=".", check=False):
2322
"""Sort module imports."""
2423
print("sorting imports ...")
2524
args = [
2625
"isort",
27-
"--use-parentheses",
28-
"--trailing-comma",
29-
"--force-grid-wrap",
30-
"0",
31-
"--multi-line",
32-
"3",
26+
"--profile",
27+
"black",
3328
"-l",
3429
str(line_length),
35-
"-rc",
36-
"--atomic",
3730
targets,
3831
]
32+
if check:
33+
args.append("--check-only")
3934
ctx.run(" ".join(args))
4035

4136

42-
def _fmt_cmd(line_length: int, targets: Union[str, List[str]]) -> str:
37+
def _fmt_cmd(line_length: int, targets: Union[str, List[str]], check=False) -> str:
4338
args = ["black", "--line-length", str(line_length)]
39+
if check:
40+
args.append("--check")
4441
if isinstance(targets, (list, tuple, set)):
4542
args.extend(targets)
4643
else:
@@ -51,23 +48,21 @@ def _fmt_cmd(line_length: int, targets: Union[str, List[str]]) -> str:
5148
@task(
5249
pre=[sort],
5350
help={
54-
"line-length": "How many characters per line to allow. [default: {}]".format(
55-
constants.LINE_LENGTH
56-
),
51+
"line-length": "How many characters per line to allow."
52+
f" [default: {constants.LINE_LENGTH}]",
5753
"targets": "Paths/directories to format. [default: . ]",
5854
},
5955
)
60-
def fmt(ctx, line_length=constants.LINE_LENGTH, targets="."):
56+
def fmt(ctx, line_length=constants.LINE_LENGTH, targets=".", check=False):
6157
"""Format python source code & sort imports."""
6258
print("formatting ...")
63-
ctx.run(_fmt_cmd(line_length, targets))
59+
ctx.run(_fmt_cmd(line_length, targets, check))
6460

6561

6662
@task(
6763
help={
68-
"line-length": "How many characters per line to allow. [default: {}]".format(
69-
constants.LINE_LENGTH
70-
),
64+
"line-length": "How many characters per line to allow."
65+
f" [default: {constants.LINE_LENGTH}]",
7166
"targets": "Paths/directories to format. [default: . ]",
7267
},
7368
)

blue_chip/tasks/linting.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,23 @@
99

1010
from blue_chip import config, constants
1111

12-
# pylint:disable=protected-access
13-
1412
__all__ = ["cfg_lint", "lint"]
1513

1614

1715
STAR_SEP = "*" * get_terminal_size().columns
1816

1917

2018
@task
21-
def cfg_lint(ctx): # pylint:disable=unused-argument
19+
def cfg_lint(ctx, force=False): # pylint:disable=unused-argument
2220
"""Configure prospector profiles."""
23-
if constants.BC_LINTRC_PATH.exists():
21+
if constants.BC_LINTRC_PATH.exists() and not force:
2422
return
2523
lintrc_path = pathlib.Path(constants.BC_LINTRC_PATH)
26-
lintrc_path.mkdir(exist_ok=False)
24+
lintrc_path.mkdir(exist_ok=True)
2725
for profile_name, profile_content in config.data.LINT_DATA.items():
2826
profile_path = lintrc_path / profile_name
2927
print(f" Initializing {profile_name} ...")
30-
with open(profile_path, mode="w") as f_out:
28+
with open(profile_path, mode="w", encoding="utf-8") as f_out:
3129
f_out.write(profile_content)
3230
print(
3331
"Lint configuration profiles created at:\n",

0 commit comments

Comments
 (0)