mirror of
https://github.com/python-poetry/install.python-poetry.org.git
synced 2024-11-25 15:30:56 -05:00
chore: pull in CI config from poetry, reformat as needed
This commit is contained in:
parent
9b64f71d73
commit
860c5691d6
4 changed files with 102 additions and 55 deletions
20
.flake8
20
.flake8
|
@ -1,3 +1,19 @@
|
||||||
[flake8]
|
[flake8]
|
||||||
max-line-length = 88
|
min_python_version = 3.6.0
|
||||||
ignore = E501, E203, W503
|
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,
|
||||||
|
|
|
@ -1,34 +1,72 @@
|
||||||
|
ci:
|
||||||
|
autofix_prs: false
|
||||||
|
|
||||||
repos:
|
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
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v4.3.0
|
rev: v4.3.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
- id: debug-statements
|
- id: check-merge-conflict
|
||||||
- id: pretty-format-json
|
- id: check-case-conflict
|
||||||
args:
|
|
||||||
- --autofix
|
|
||||||
- id: check-json
|
- 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
|
- repo: https://github.com/asottile/pyupgrade
|
||||||
rev: v2.34.0
|
rev: v2.37.3
|
||||||
hooks:
|
hooks:
|
||||||
- id: pyupgrade
|
- id: pyupgrade
|
||||||
args: [--py36-plus]
|
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
|
||||||
|
|
|
@ -4,9 +4,9 @@ This script will install Poetry and its dependencies in an isolated fashion.
|
||||||
|
|
||||||
It will perform the following steps:
|
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.
|
* 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
|
- `~/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
|
- `%APPDATA%\pypoetry` on Windows
|
||||||
* Update pip inside the virtual environment to avoid bugs in older versions.
|
* 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.
|
* 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:
|
for option in options:
|
||||||
codes.append(OPTIONS[option])
|
codes.append(OPTIONS[option])
|
||||||
|
|
||||||
return "\033[{}m".format(";".join(map(str, codes)))
|
return f"\033[{';'.join(map(str, codes))}m"
|
||||||
|
|
||||||
|
|
||||||
STYLES = {
|
STYLES = {
|
||||||
|
@ -107,8 +107,8 @@ def is_decorated():
|
||||||
if WINDOWS:
|
if WINDOWS:
|
||||||
return (
|
return (
|
||||||
os.getenv("ANSICON") is not None
|
os.getenv("ANSICON") is not None
|
||||||
or "ON" == os.getenv("ConEmuANSI")
|
or os.getenv("ConEmuANSI") == "ON"
|
||||||
or "xterm" == os.getenv("Term")
|
or os.getenv("Term") == "xterm"
|
||||||
)
|
)
|
||||||
|
|
||||||
if not hasattr(sys.stdout, "fileno"):
|
if not hasattr(sys.stdout, "fileno"):
|
||||||
|
@ -532,8 +532,9 @@ class Installer:
|
||||||
self._write(
|
self._write(
|
||||||
colorize(
|
colorize(
|
||||||
"warning",
|
"warning",
|
||||||
f"You are installing {version}. When using the current installer, this version does not support "
|
f"You are installing {version}. When using the current installer,"
|
||||||
f"updating using the 'self update' command. Please use 1.1.7 or later.",
|
" this version does not support updating using the 'self update'"
|
||||||
|
" command. Please use 1.1.7 or later.",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if not self._accept_all:
|
if not self._accept_all:
|
||||||
|
@ -558,9 +559,7 @@ class Installer:
|
||||||
Installs Poetry in $POETRY_HOME.
|
Installs Poetry in $POETRY_HOME.
|
||||||
"""
|
"""
|
||||||
self._write(
|
self._write(
|
||||||
"Installing {} ({})".format(
|
f"Installing {colorize('info', 'Poetry')} ({colorize('info', version)})"
|
||||||
colorize("info", "Poetry"), colorize("info", version)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.make_env(version) as env:
|
with self.make_env(version) as env:
|
||||||
|
@ -573,9 +572,7 @@ class Installer:
|
||||||
|
|
||||||
def uninstall(self) -> int:
|
def uninstall(self) -> int:
|
||||||
if not self.data_dir.exists():
|
if not self.data_dir.exists():
|
||||||
self._write(
|
self._write(f"{colorize('info', 'Poetry')} is not currently installed.")
|
||||||
"{} is not currently installed.".format(colorize("info", "Poetry"))
|
|
||||||
)
|
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
@ -585,12 +582,10 @@ class Installer:
|
||||||
|
|
||||||
if version:
|
if version:
|
||||||
self._write(
|
self._write(
|
||||||
"Removing {} ({})".format(
|
f"Removing {colorize('info', 'Poetry')} ({colorize('b', version)})"
|
||||||
colorize("info", "Poetry"), colorize("b", version)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self._write("Removing {}".format(colorize("info", "Poetry")))
|
self._write(f"Removing {colorize('info', 'Poetry')}")
|
||||||
|
|
||||||
shutil.rmtree(str(self.data_dir))
|
shutil.rmtree(str(self.data_dir))
|
||||||
for script in ["poetry", "poetry.bat", "poetry.exe"]:
|
for script in ["poetry", "poetry.bat", "poetry.exe"]:
|
||||||
|
@ -601,11 +596,8 @@ class Installer:
|
||||||
|
|
||||||
def _install_comment(self, version: str, message: str):
|
def _install_comment(self, version: str, message: str):
|
||||||
self._overwrite(
|
self._overwrite(
|
||||||
"Installing {} ({}): {}".format(
|
f"Installing {colorize('info', 'Poetry')} ({colorize('b', version)}):"
|
||||||
colorize("info", "Poetry"),
|
f" {colorize('comment', message)}"
|
||||||
colorize("b", version),
|
|
||||||
colorize("comment", message),
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
|
@ -708,11 +700,12 @@ class Installer:
|
||||||
def get_windows_path_var(self) -> Optional[str]:
|
def get_windows_path_var(self) -> Optional[str]:
|
||||||
import winreg
|
import winreg
|
||||||
|
|
||||||
with winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER) as root:
|
with winreg.ConnectRegistry(
|
||||||
with winreg.OpenKey(root, "Environment", 0, winreg.KEY_ALL_ACCESS) as key:
|
None, winreg.HKEY_CURRENT_USER
|
||||||
path, _ = winreg.QueryValueEx(key, "PATH")
|
) 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:
|
def display_post_message_fish(self, version: str) -> None:
|
||||||
fish_user_paths = subprocess.check_output(
|
fish_user_paths = subprocess.check_output(
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
[tool.isort]
|
[tool.isort]
|
||||||
|
py_version = 36
|
||||||
profile = "black"
|
profile = "black"
|
||||||
force_single_line = true
|
force_single_line = true
|
||||||
atomic = true
|
combine_as_imports = true
|
||||||
lines_after_imports = 2
|
|
||||||
lines_between_types = 1
|
lines_between_types = 1
|
||||||
filter_files = true
|
lines_after_imports = 2
|
||||||
|
|
||||||
|
|
||||||
[tool.black]
|
[tool.black]
|
||||||
line-length = 88
|
target-version = ['py36']
|
||||||
include = '\.pyi?$'
|
preview = true
|
||||||
|
|
Loading…
Reference in a new issue