summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPradyun Gedam <pradyunsg@users.noreply.github.com>2021-07-23 17:11:56 +0100
committerPradyun Gedam <pradyunsg@users.noreply.github.com>2021-07-23 17:11:56 +0100
commitc7ee560e00b85f7486b452c14ff49e4737996eda (patch)
tree30049feb0e763c21c2d8633fe6f5f3e08056c334 /tools
parentdf98167fe54b99f61dd000ae619fd4b1c634c039 (diff)
downloadpip-c7ee560e00b85f7486b452c14ff49e4737996eda.tar.gz
Blacken tools/
Progresses the black formatting of the codebase further.
Diffstat (limited to 'tools')
-rw-r--r--tools/release/__init__.py41
-rw-r--r--tools/tox_pip.py30
2 files changed, 44 insertions, 27 deletions
diff --git a/tools/release/__init__.py b/tools/release/__init__.py
index ec3a0eeb7..cc60f442f 100644
--- a/tools/release/__init__.py
+++ b/tools/release/__init__.py
@@ -29,7 +29,7 @@ def get_version_from_arguments(session: Session) -> Optional[str]:
# https://github.com/theacodes/nox/pull/378
os.path.join(session.bin, "python"), # type: ignore
"tools/release/check_version.py",
- version
+ version,
]
not_ok = subprocess.run(cmd).returncode
if not_ok:
@@ -47,8 +47,7 @@ def modified_files_in_git(*args: str) -> int:
def get_author_list() -> List[str]:
- """Get the list of authors from Git commits.
- """
+ """Get the list of authors from Git commits."""
# subprocess because session.run doesn't give us stdout
# only use names in list of Authors
result = subprocess.run(
@@ -103,13 +102,16 @@ def update_version_file(version: str, filepath: str) -> None:
else:
f.write(line)
- assert file_modified, \
- f"Version file {filepath} did not get modified"
+ assert file_modified, f"Version file {filepath} did not get modified"
def create_git_tag(session: Session, tag_name: str, *, message: str) -> None:
session.run(
- "git", "tag", "-m", message, tag_name, external=True, silent=True,
+ # fmt: off
+ "git", "tag", "-m", message, tag_name,
+ # fmt: on
+ external=True,
+ silent=True,
)
@@ -148,8 +150,8 @@ def have_files_in_folder(folder_name: str) -> bool:
@contextlib.contextmanager
def workdir(
- nox_session: Session,
- dir_path: pathlib.Path,
+ nox_session: Session,
+ dir_path: pathlib.Path,
) -> Iterator[pathlib.Path]:
"""Temporarily chdir when entering CM and chdir back on exit."""
orig_dir = pathlib.Path.cwd()
@@ -164,35 +166,42 @@ def workdir(
@contextlib.contextmanager
def isolated_temporary_checkout(
- nox_session: Session,
- target_ref: str,
+ nox_session: Session,
+ target_ref: str,
) -> Iterator[pathlib.Path]:
"""Make a clean checkout of a given version in tmp dir."""
with tempfile.TemporaryDirectory() as tmp_dir_path:
tmp_dir = pathlib.Path(tmp_dir_path)
- git_checkout_dir = tmp_dir / f'pip-build-{target_ref}'
+ git_checkout_dir = tmp_dir / f"pip-build-{target_ref}"
nox_session.run(
- 'git', 'worktree', 'add', '--force', '--checkout',
+ # fmt: off
+ "git", "worktree", "add", "--force", "--checkout",
str(git_checkout_dir), str(target_ref),
- external=True, silent=True,
+ # fmt: on
+ external=True,
+ silent=True,
)
try:
yield git_checkout_dir
finally:
nox_session.run(
- 'git', 'worktree', 'remove', '--force',
- str(git_checkout_dir),
- external=True, silent=True,
+ # fmt: off
+ "git", "worktree", "remove", "--force", str(git_checkout_dir),
+ # fmt: on
+ external=True,
+ silent=True,
)
def get_git_untracked_files() -> Iterator[str]:
"""List all local file paths that aren't tracked by Git."""
git_ls_files_cmd = (
+ # fmt: off
"git", "ls-files",
"--ignored", "--exclude-standard",
"--others", "--", ".",
+ # fmt: on
)
# session.run doesn't seem to return any output:
ls_files_out = subprocess.check_output(git_ls_files_cmd, text=True)
diff --git a/tools/tox_pip.py b/tools/tox_pip.py
index 6a0e2dae9..671518029 100644
--- a/tools/tox_pip.py
+++ b/tools/tox_pip.py
@@ -5,25 +5,33 @@ import sys
from glob import glob
from typing import List
-VIRTUAL_ENV = os.environ['VIRTUAL_ENV']
-TOX_PIP_DIR = os.path.join(VIRTUAL_ENV, 'pip')
+VIRTUAL_ENV = os.environ["VIRTUAL_ENV"]
+TOX_PIP_DIR = os.path.join(VIRTUAL_ENV, "pip")
def pip(args: List[str]) -> None:
# First things first, get a recent (stable) version of pip.
if not os.path.exists(TOX_PIP_DIR):
- subprocess.check_call([sys.executable, '-m', 'pip',
- '--disable-pip-version-check',
- 'install', '-t', TOX_PIP_DIR,
- 'pip'])
- shutil.rmtree(glob(os.path.join(TOX_PIP_DIR, 'pip-*.dist-info'))[0])
+ subprocess.check_call(
+ [
+ sys.executable,
+ "-m",
+ "pip",
+ "--disable-pip-version-check",
+ "install",
+ "-t",
+ TOX_PIP_DIR,
+ "pip",
+ ]
+ )
+ shutil.rmtree(glob(os.path.join(TOX_PIP_DIR, "pip-*.dist-info"))[0])
# And use that version.
- pypath_env = os.environ.get('PYTHONPATH')
+ pypath_env = os.environ.get("PYTHONPATH")
pypath = pypath_env.split(os.pathsep) if pypath_env is not None else []
pypath.insert(0, TOX_PIP_DIR)
- os.environ['PYTHONPATH'] = os.pathsep.join(pypath)
- subprocess.check_call([sys.executable, '-m', 'pip'] + args)
+ os.environ["PYTHONPATH"] = os.pathsep.join(pypath)
+ subprocess.check_call([sys.executable, "-m", "pip"] + args)
-if __name__ == '__main__':
+if __name__ == "__main__":
pip(sys.argv[1:])