1
0
Fork 0
mirror of https://github.com/python-poetry/install.python-poetry.org.git synced 2024-11-21 21:50:58 -05:00

chore: pull in CI config from poetry, reformat as needed

This commit is contained in:
Bjorn Neergaard 2022-09-07 01:50:56 -06:00
parent 9b64f71d73
commit 860c5691d6
4 changed files with 102 additions and 55 deletions

20
.flake8
View file

@ -1,3 +1,19 @@
[flake8]
max-line-length = 88
ignore = E501, E203, W503
min_python_version = 3.6.0
max-line-length = 120
ban-relative-imports = true
# flake8-use-fstring: https://github.com/MichaelKim0407/flake8-use-fstring#--percent-greedy-and---format-greedy
format-greedy = 0
inline-quotes = double
enable-extensions = TC, TC1
type-checking-exempt-modules = typing, typing-extensions
eradicate-whitelist-extend = ^-.*;
extend-ignore =
# E203: Whitespace before ':' (pycqa/pycodestyle#373)
E203,
# SIM106: Handle error-cases first
SIM106,
# ANN101: Missing type annotation for self in method
ANN101,
# ANN102: Missing type annotation for cls in classmethod
ANN102,

View file

@ -1,34 +1,72 @@
ci:
autofix_prs: false
repos:
- repo: https://github.com/psf/black
rev: 22.8.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear==22.7.1
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: debug-statements
- id: pretty-format-json
args:
- --autofix
- id: check-merge-conflict
- id: check-case-conflict
- id: check-json
- id: check-toml
- id: check-yaml
- id: pretty-format-json
args: [--autofix, --no-ensure-ascii, --no-sort-keys]
- id: check-ast
- id: debug-statements
- id: check-docstring-first
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
- id: python-check-mock-methods
- id: python-use-type-annotations
- id: python-check-blanket-noqa
- repo: https://github.com/asottile/yesqa
rev: v1.4.0
hooks:
- id: yesqa
additional_dependencies: &flake8_deps
# - flake8-annotations==2.9.0
- flake8-broken-line==0.5.0
- flake8-bugbear==22.7.1
- flake8-comprehensions==3.10.0
- flake8-eradicate==1.3.0
- flake8-quotes==3.3.1
- flake8-simplify==0.19.3
- flake8-tidy-imports==4.8.0
- flake8-type-checking==2.1.2
- flake8-typing-imports==1.12.0
- flake8-use-fstring==1.4
- pep8-naming==0.13.1
- repo: https://github.com/asottile/pyupgrade
rev: v2.34.0
rev: v2.37.3
hooks:
- id: pyupgrade
args: [--py36-plus]
- repo: https://github.com/hadialqattan/pycln
rev: v2.1.1
hooks:
- id: pycln
args: [--all]
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 22.6.0
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 5.0.4
hooks:
- id: flake8
additional_dependencies: *flake8_deps

View file

@ -4,9 +4,9 @@ This script will install Poetry and its dependencies in an isolated fashion.
It will perform the following steps:
* Create a new virtual environment using the built-in venv module, or the virtualenv zipapp if venv is unavailable.
This will be created at a platform-specific path (or `$POETRY_HOME` if `$POETRY_HOME` is set:
This will be created at a platform-specific path (or `$POETRY_HOME` if set):
- `~/Library/Application Support/pypoetry` on macOS
- `$XDG_DATA_HOME/pypoetry` on Linux/Unix (`$XDG_DATA_HOME` is `~/.local/share` if unset)
- `$XDG_DATA_HOME/pypoetry` on Linux/Unix (`XDG_DATA_HOME` is `~/.local/share` by default)
- `%APPDATA%\pypoetry` on Windows
* Update pip inside the virtual environment to avoid bugs in older versions.
* Install the latest (or a given) version of Poetry inside this virtual environment using pip.
@ -90,7 +90,7 @@ def style(fg, bg, options):
for option in options:
codes.append(OPTIONS[option])
return "\033[{}m".format(";".join(map(str, codes)))
return f"\033[{';'.join(map(str, codes))}m"
STYLES = {
@ -107,8 +107,8 @@ def is_decorated():
if WINDOWS:
return (
os.getenv("ANSICON") is not None
or "ON" == os.getenv("ConEmuANSI")
or "xterm" == os.getenv("Term")
or os.getenv("ConEmuANSI") == "ON"
or os.getenv("Term") == "xterm"
)
if not hasattr(sys.stdout, "fileno"):
@ -532,8 +532,9 @@ class Installer:
self._write(
colorize(
"warning",
f"You are installing {version}. When using the current installer, this version does not support "
f"updating using the 'self update' command. Please use 1.1.7 or later.",
f"You are installing {version}. When using the current installer,"
" this version does not support updating using the 'self update'"
" command. Please use 1.1.7 or later.",
)
)
if not self._accept_all:
@ -558,9 +559,7 @@ class Installer:
Installs Poetry in $POETRY_HOME.
"""
self._write(
"Installing {} ({})".format(
colorize("info", "Poetry"), colorize("info", version)
)
f"Installing {colorize('info', 'Poetry')} ({colorize('info', version)})"
)
with self.make_env(version) as env:
@ -573,9 +572,7 @@ class Installer:
def uninstall(self) -> int:
if not self.data_dir.exists():
self._write(
"{} is not currently installed.".format(colorize("info", "Poetry"))
)
self._write(f"{colorize('info', 'Poetry')} is not currently installed.")
return 1
@ -585,12 +582,10 @@ class Installer:
if version:
self._write(
"Removing {} ({})".format(
colorize("info", "Poetry"), colorize("b", version)
)
f"Removing {colorize('info', 'Poetry')} ({colorize('b', version)})"
)
else:
self._write("Removing {}".format(colorize("info", "Poetry")))
self._write(f"Removing {colorize('info', 'Poetry')}")
shutil.rmtree(str(self.data_dir))
for script in ["poetry", "poetry.bat", "poetry.exe"]:
@ -601,11 +596,8 @@ class Installer:
def _install_comment(self, version: str, message: str):
self._overwrite(
"Installing {} ({}): {}".format(
colorize("info", "Poetry"),
colorize("b", version),
colorize("comment", message),
)
f"Installing {colorize('info', 'Poetry')} ({colorize('b', version)}):"
f" {colorize('comment', message)}"
)
@contextmanager
@ -708,11 +700,12 @@ class Installer:
def get_windows_path_var(self) -> Optional[str]:
import winreg
with winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER) as root:
with winreg.OpenKey(root, "Environment", 0, winreg.KEY_ALL_ACCESS) as key:
path, _ = winreg.QueryValueEx(key, "PATH")
with winreg.ConnectRegistry(
None, winreg.HKEY_CURRENT_USER
) as root, winreg.OpenKey(root, "Environment", 0, winreg.KEY_ALL_ACCESS) as key:
path, _ = winreg.QueryValueEx(key, "PATH")
return path
return path
def display_post_message_fish(self, version: str) -> None:
fish_user_paths = subprocess.check_output(

View file

@ -1,12 +1,12 @@
[tool.isort]
py_version = 36
profile = "black"
force_single_line = true
atomic = true
lines_after_imports = 2
combine_as_imports = true
lines_between_types = 1
filter_files = true
lines_after_imports = 2
[tool.black]
line-length = 88
include = '\.pyi?$'
target-version = ['py36']
preview = true