Skip to content

Commit

Permalink
👹 Feed the hobgoblins (delint).
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Dec 23, 2024
1 parent a9c1fe4 commit 088647e
Show file tree
Hide file tree
Showing 39 changed files with 2,066 additions and 1,769 deletions.
45 changes: 22 additions & 23 deletions bin/pip_constraint_helpers.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
"""A set of functions helping generating pip constraint files."""

import functools
import os
import platform
import subprocess # noqa: S404
import sys

PYTHON_IMPLEMENTATION_MAP = { # noqa: WPS407
'cpython': 'cp',
'ironpython': 'ip',
'jython': 'jy',
'python': 'py',
'pypy': 'pp',
"cpython": "cp",
"ironpython": "ip",
"jython": "jy",
"python": "py",
"pypy": "pp",
}
PYTHON_IMPLEMENTATION = platform.python_implementation()

Expand All @@ -33,11 +34,10 @@ def get_runtime_python_tag():
python_tag_prefix = PYTHON_IMPLEMENTATION_MAP.get(sys_impl, sys_impl)

# pylint: disable=possibly-unused-variable
python_minor_ver_tag = ''.join(map(str, python_minor_ver))
python_minor_ver_tag = "".join(map(str, python_minor_ver))

return (
'{python_tag_prefix!s}{python_minor_ver_tag!s}'.
format(**locals()) # noqa: WPS421
"{python_tag_prefix!s}{python_minor_ver_tag!s}".format(**locals()) # noqa: WPS421
)


Expand All @@ -54,21 +54,20 @@ def get_constraint_file_path(req_dir, toxenv, python_tag):
# pylint: disable=possibly-unused-variable
platform_machine = platform.machine().lower()

if toxenv in {'py', 'python'}:
extra_prefix = 'py' if PYTHON_IMPLEMENTATION == 'PyPy' else ''
toxenv = '{prefix}py{ver}'.format(
if toxenv in {"py", "python"}:
extra_prefix = "py" if PYTHON_IMPLEMENTATION == "PyPy" else ""
toxenv = "{prefix}py{ver}".format(
prefix=extra_prefix,
ver=python_tag[2:],
)

if sys_platform == 'linux2':
sys_platform = 'linux'
if sys_platform == "linux2":
sys_platform = "linux"

constraint_name = (
'tox-{toxenv}-{python_tag}-{sys_platform}-{platform_machine}'.
format(**locals()) # noqa: WPS421
"tox-{toxenv}-{python_tag}-{sys_platform}-{platform_machine}".format(**locals()) # noqa: WPS421
)
return os.path.join(req_dir, os.path.extsep.join((constraint_name, 'txt')))
return os.path.join(req_dir, os.path.extsep.join((constraint_name, "txt")))


def make_pip_cmd(pip_args, constraint_file_path):
Expand All @@ -79,14 +78,15 @@ def make_pip_cmd(pip_args, constraint_file_path):
:returns: pip command.
"""
pip_cmd = [sys.executable, '-m', 'pip'] + pip_args
pip_cmd = [sys.executable, "-m", "pip"] + pip_args
if os.path.isfile(constraint_file_path):
pip_cmd += ['--constraint', constraint_file_path]
pip_cmd += ["--constraint", constraint_file_path]
else:
print_info(
'WARNING: The expected pinned constraints file for the current '
'env does not exist (should be "{constraint_file_path}").'.
format(**locals()), # noqa: WPS421
"WARNING: The expected pinned constraints file for the current "
'env does not exist (should be "{constraint_file_path}").'.format(
**locals()
), # noqa: WPS421
)
return pip_cmd

Expand All @@ -97,7 +97,6 @@ def run_cmd(cmd):
:param cmd: The command to invoke.
"""
print_info(
'Invoking the following command: {cmd}'.
format(cmd=' '.join(cmd)),
"Invoking the following command: {cmd}".format(cmd=" ".join(cmd)),
)
subprocess.check_call(cmd) # noqa: S603
4 changes: 2 additions & 2 deletions cheroot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@


try:
__version__ = metadata.version('cheroot')
__version__ = metadata.version("cheroot")
except Exception:
__version__ = 'unknown'
__version__ = "unknown"
2 changes: 1 addition & 1 deletion cheroot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

from .cli import main

if __name__ == '__main__':
if __name__ == "__main__":
main()
27 changes: 14 additions & 13 deletions cheroot/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,45 @@

try:
import ssl

IS_ABOVE_OPENSSL10 = ssl.OPENSSL_VERSION_INFO >= (1, 1)
del ssl
except ImportError:
IS_ABOVE_OPENSSL10 = None


IS_CI = bool(os.getenv('CI'))
IS_GITHUB_ACTIONS_WORKFLOW = bool(os.getenv('GITHUB_WORKFLOW'))
IS_CI = bool(os.getenv("CI"))
IS_GITHUB_ACTIONS_WORKFLOW = bool(os.getenv("GITHUB_WORKFLOW"))


IS_PYPY = platform.python_implementation() == 'PyPy'
IS_PYPY = platform.python_implementation() == "PyPy"


SYS_PLATFORM = platform.system()
IS_WINDOWS = SYS_PLATFORM == 'Windows'
IS_LINUX = SYS_PLATFORM == 'Linux'
IS_MACOS = SYS_PLATFORM == 'Darwin'
IS_SOLARIS = SYS_PLATFORM == 'SunOS'
IS_WINDOWS = SYS_PLATFORM == "Windows"
IS_LINUX = SYS_PLATFORM == "Linux"
IS_MACOS = SYS_PLATFORM == "Darwin"
IS_SOLARIS = SYS_PLATFORM == "SunOS"

PLATFORM_ARCH = platform.machine()
IS_PPC = PLATFORM_ARCH.startswith('ppc')
IS_PPC = PLATFORM_ARCH.startswith("ppc")


def ntob(n, encoding='ISO-8859-1'):
def ntob(n, encoding="ISO-8859-1"):
"""Return the native string as bytes in the given encoding."""
assert_native(n)
# In Python 3, the native string type is unicode
return n.encode(encoding)


def ntou(n, encoding='ISO-8859-1'):
def ntou(n, encoding="ISO-8859-1"):
"""Return the native string as Unicode with the given encoding."""
assert_native(n)
# In Python 3, the native string type is unicode
return n


def bton(b, encoding='ISO-8859-1'):
def bton(b, encoding="ISO-8859-1"):
"""Return the byte string as native string in the given encoding."""
return b.decode(encoding)

Expand All @@ -57,7 +58,7 @@ def assert_native(n):
"""
if not isinstance(n, str):
raise TypeError('n must be a native str (got %s)' % type(n).__name__)
raise TypeError("n must be a native str (got %s)" % type(n).__name__)


def extract_bytes(mv):
Expand All @@ -80,5 +81,5 @@ def extract_bytes(mv):
return mv

raise ValueError(
'extract_bytes() only accepts bytes and memoryview/buffer',
"extract_bytes() only accepts bytes and memoryview/buffer",
)
1 change: 0 additions & 1 deletion cheroot/_compat.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ def ntob(n: str, encoding: str = ...) -> bytes: ...
def ntou(n: str, encoding: str = ...) -> str: ...
def bton(b: bytes, encoding: str = ...) -> str: ...
def assert_native(n: str) -> None: ...

def extract_bytes(mv: Union[memoryview, bytes]) -> bytes: ...
Loading

0 comments on commit 088647e

Please sign in to comment.