Skip to content

Commit 860c569

Browse files
committed
chore: pull in CI config from poetry, reformat as needed
1 parent 9b64f71 commit 860c569

File tree

4 files changed

+101
-54
lines changed

4 files changed

+101
-54
lines changed

.flake8

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
11
[flake8]
2-
max-line-length = 88
3-
ignore = E501, E203, W503
2+
min_python_version = 3.6.0
3+
max-line-length = 120
4+
ban-relative-imports = true
5+
# flake8-use-fstring: https://github.com/MichaelKim0407/flake8-use-fstring#--percent-greedy-and---format-greedy
6+
format-greedy = 0
7+
inline-quotes = double
8+
enable-extensions = TC, TC1
9+
type-checking-exempt-modules = typing, typing-extensions
10+
eradicate-whitelist-extend = ^-.*;
11+
extend-ignore =
12+
# E203: Whitespace before ':' (pycqa/pycodestyle#373)
13+
E203,
14+
# SIM106: Handle error-cases first
15+
SIM106,
16+
# ANN101: Missing type annotation for self in method
17+
ANN101,
18+
# ANN102: Missing type annotation for cls in classmethod
19+
ANN102,

.pre-commit-config.yaml

Lines changed: 59 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,72 @@
1+
ci:
2+
autofix_prs: false
3+
14
repos:
2-
- repo: https://github.com/psf/black
3-
rev: 22.8.0
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v4.3.0
47
hooks:
5-
- id: black
8+
- id: trailing-whitespace
9+
- id: end-of-file-fixer
10+
- id: check-merge-conflict
11+
- id: check-case-conflict
12+
- id: check-json
13+
- id: check-toml
14+
- id: check-yaml
15+
- id: pretty-format-json
16+
args: [--autofix, --no-ensure-ascii, --no-sort-keys]
17+
- id: check-ast
18+
- id: debug-statements
19+
- id: check-docstring-first
620

7-
- repo: https://github.com/PyCQA/flake8
8-
rev: 5.0.4
21+
- repo: https://github.com/pre-commit/pygrep-hooks
22+
rev: v1.9.0
923
hooks:
10-
- id: flake8
11-
additional_dependencies:
24+
- id: python-check-mock-methods
25+
- id: python-use-type-annotations
26+
- id: python-check-blanket-noqa
27+
28+
- repo: https://github.com/asottile/yesqa
29+
rev: v1.4.0
30+
hooks:
31+
- id: yesqa
32+
additional_dependencies: &flake8_deps
33+
# - flake8-annotations==2.9.0
34+
- flake8-broken-line==0.5.0
1235
- flake8-bugbear==22.7.1
36+
- flake8-comprehensions==3.10.0
37+
- flake8-eradicate==1.3.0
38+
- flake8-quotes==3.3.1
39+
- flake8-simplify==0.19.3
40+
- flake8-tidy-imports==4.8.0
41+
- flake8-type-checking==2.1.2
42+
- flake8-typing-imports==1.12.0
43+
- flake8-use-fstring==1.4
44+
- pep8-naming==0.13.1
1345

14-
- repo: https://github.com/PyCQA/isort
46+
- repo: https://github.com/asottile/pyupgrade
47+
rev: v2.37.3
48+
hooks:
49+
- id: pyupgrade
50+
args: [--py36-plus]
51+
52+
- repo: https://github.com/hadialqattan/pycln
53+
rev: v2.1.1
54+
hooks:
55+
- id: pycln
56+
args: [--all]
57+
58+
- repo: https://github.com/pycqa/isort
1559
rev: 5.10.1
1660
hooks:
1761
- id: isort
1862

19-
- repo: https://github.com/pre-commit/pre-commit-hooks
20-
rev: v4.3.0
63+
- repo: https://github.com/psf/black
64+
rev: 22.6.0
2165
hooks:
22-
- id: trailing-whitespace
23-
- id: end-of-file-fixer
24-
- id: debug-statements
25-
- id: pretty-format-json
26-
args:
27-
- --autofix
28-
- id: check-json
66+
- id: black
2967

30-
- repo: https://github.com/asottile/pyupgrade
31-
rev: v2.34.0
68+
- repo: https://github.com/pycqa/flake8
69+
rev: 5.0.4
3270
hooks:
33-
- id: pyupgrade
34-
args: [--py36-plus]
71+
- id: flake8
72+
additional_dependencies: *flake8_deps

install-poetry.py

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
55
It will perform the following steps:
66
* Create a new virtual environment using the built-in venv module, or the virtualenv zipapp if venv is unavailable.
7-
This will be created at a platform-specific path (or `$POETRY_HOME` if `$POETRY_HOME` is set:
7+
This will be created at a platform-specific path (or `$POETRY_HOME` if set):
88
- `~/Library/Application Support/pypoetry` on macOS
9-
- `$XDG_DATA_HOME/pypoetry` on Linux/Unix (`$XDG_DATA_HOME` is `~/.local/share` if unset)
9+
- `$XDG_DATA_HOME/pypoetry` on Linux/Unix (`XDG_DATA_HOME` is `~/.local/share` by default)
1010
- `%APPDATA%\pypoetry` on Windows
1111
* Update pip inside the virtual environment to avoid bugs in older versions.
1212
* Install the latest (or a given) version of Poetry inside this virtual environment using pip.
@@ -90,7 +90,7 @@ def style(fg, bg, options):
9090
for option in options:
9191
codes.append(OPTIONS[option])
9292

93-
return "\033[{}m".format(";".join(map(str, codes)))
93+
return f"\033[{';'.join(map(str, codes))}m"
9494

9595

9696
STYLES = {
@@ -107,8 +107,8 @@ def is_decorated():
107107
if WINDOWS:
108108
return (
109109
os.getenv("ANSICON") is not None
110-
or "ON" == os.getenv("ConEmuANSI")
111-
or "xterm" == os.getenv("Term")
110+
or os.getenv("ConEmuANSI") == "ON"
111+
or os.getenv("Term") == "xterm"
112112
)
113113

114114
if not hasattr(sys.stdout, "fileno"):
@@ -532,8 +532,9 @@ def _is_self_upgrade_supported(x):
532532
self._write(
533533
colorize(
534534
"warning",
535-
f"You are installing {version}. When using the current installer, this version does not support "
536-
f"updating using the 'self update' command. Please use 1.1.7 or later.",
535+
f"You are installing {version}. When using the current installer,"
536+
" this version does not support updating using the 'self update'"
537+
" command. Please use 1.1.7 or later.",
537538
)
538539
)
539540
if not self._accept_all:
@@ -558,9 +559,7 @@ def install(self, version):
558559
Installs Poetry in $POETRY_HOME.
559560
"""
560561
self._write(
561-
"Installing {} ({})".format(
562-
colorize("info", "Poetry"), colorize("info", version)
563-
)
562+
f"Installing {colorize('info', 'Poetry')} ({colorize('info', version)})"
564563
)
565564

566565
with self.make_env(version) as env:
@@ -573,9 +572,7 @@ def install(self, version):
573572

574573
def uninstall(self) -> int:
575574
if not self.data_dir.exists():
576-
self._write(
577-
"{} is not currently installed.".format(colorize("info", "Poetry"))
578-
)
575+
self._write(f"{colorize('info', 'Poetry')} is not currently installed.")
579576

580577
return 1
581578

@@ -585,12 +582,10 @@ def uninstall(self) -> int:
585582

586583
if version:
587584
self._write(
588-
"Removing {} ({})".format(
589-
colorize("info", "Poetry"), colorize("b", version)
590-
)
585+
f"Removing {colorize('info', 'Poetry')} ({colorize('b', version)})"
591586
)
592587
else:
593-
self._write("Removing {}".format(colorize("info", "Poetry")))
588+
self._write(f"Removing {colorize('info', 'Poetry')}")
594589

595590
shutil.rmtree(str(self.data_dir))
596591
for script in ["poetry", "poetry.bat", "poetry.exe"]:
@@ -601,11 +596,8 @@ def uninstall(self) -> int:
601596

602597
def _install_comment(self, version: str, message: str):
603598
self._overwrite(
604-
"Installing {} ({}): {}".format(
605-
colorize("info", "Poetry"),
606-
colorize("b", version),
607-
colorize("comment", message),
608-
)
599+
f"Installing {colorize('info', 'Poetry')} ({colorize('b', version)}):"
600+
f" {colorize('comment', message)}"
609601
)
610602

611603
@contextmanager
@@ -708,11 +700,12 @@ def display_post_message_windows(self, version: str) -> None:
708700
def get_windows_path_var(self) -> Optional[str]:
709701
import winreg
710702

711-
with winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER) as root:
712-
with winreg.OpenKey(root, "Environment", 0, winreg.KEY_ALL_ACCESS) as key:
713-
path, _ = winreg.QueryValueEx(key, "PATH")
703+
with winreg.ConnectRegistry(
704+
None, winreg.HKEY_CURRENT_USER
705+
) as root, winreg.OpenKey(root, "Environment", 0, winreg.KEY_ALL_ACCESS) as key:
706+
path, _ = winreg.QueryValueEx(key, "PATH")
714707

715-
return path
708+
return path
716709

717710
def display_post_message_fish(self, version: str) -> None:
718711
fish_user_paths = subprocess.check_output(

pyproject.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[tool.isort]
2+
py_version = 36
23
profile = "black"
34
force_single_line = true
4-
atomic = true
5-
lines_after_imports = 2
5+
combine_as_imports = true
66
lines_between_types = 1
7-
filter_files = true
7+
lines_after_imports = 2
88

99

1010
[tool.black]
11-
line-length = 88
12-
include = '\.pyi?$'
11+
target-version = ['py36']
12+
preview = true

0 commit comments

Comments
 (0)