Skip to content

Commit c7ee560

Browse files
committed
Blacken tools/
Progresses the black formatting of the codebase further.
1 parent df98167 commit c7ee560

File tree

3 files changed

+44
-28
lines changed

3 files changed

+44
-28
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ repos:
3030
^src/pip/_internal/req|
3131
^src/pip/_internal/vcs|
3232
^src/pip/_internal/\w+\.py$|
33-
^tools/|
3433
# Tests
3534
^tests/data|
3635
^tests/unit|

tools/release/__init__.py

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def get_version_from_arguments(session: Session) -> Optional[str]:
2929
# https://github.com/theacodes/nox/pull/378
3030
os.path.join(session.bin, "python"), # type: ignore
3131
"tools/release/check_version.py",
32-
version
32+
version,
3333
]
3434
not_ok = subprocess.run(cmd).returncode
3535
if not_ok:
@@ -47,8 +47,7 @@ def modified_files_in_git(*args: str) -> int:
4747

4848

4949
def get_author_list() -> List[str]:
50-
"""Get the list of authors from Git commits.
51-
"""
50+
"""Get the list of authors from Git commits."""
5251
# subprocess because session.run doesn't give us stdout
5352
# only use names in list of Authors
5453
result = subprocess.run(
@@ -103,13 +102,16 @@ def update_version_file(version: str, filepath: str) -> None:
103102
else:
104103
f.write(line)
105104

106-
assert file_modified, \
107-
f"Version file {filepath} did not get modified"
105+
assert file_modified, f"Version file {filepath} did not get modified"
108106

109107

110108
def create_git_tag(session: Session, tag_name: str, *, message: str) -> None:
111109
session.run(
112-
"git", "tag", "-m", message, tag_name, external=True, silent=True,
110+
# fmt: off
111+
"git", "tag", "-m", message, tag_name,
112+
# fmt: on
113+
external=True,
114+
silent=True,
113115
)
114116

115117

@@ -148,8 +150,8 @@ def have_files_in_folder(folder_name: str) -> bool:
148150

149151
@contextlib.contextmanager
150152
def workdir(
151-
nox_session: Session,
152-
dir_path: pathlib.Path,
153+
nox_session: Session,
154+
dir_path: pathlib.Path,
153155
) -> Iterator[pathlib.Path]:
154156
"""Temporarily chdir when entering CM and chdir back on exit."""
155157
orig_dir = pathlib.Path.cwd()
@@ -164,35 +166,42 @@ def workdir(
164166

165167
@contextlib.contextmanager
166168
def isolated_temporary_checkout(
167-
nox_session: Session,
168-
target_ref: str,
169+
nox_session: Session,
170+
target_ref: str,
169171
) -> Iterator[pathlib.Path]:
170172
"""Make a clean checkout of a given version in tmp dir."""
171173
with tempfile.TemporaryDirectory() as tmp_dir_path:
172174
tmp_dir = pathlib.Path(tmp_dir_path)
173-
git_checkout_dir = tmp_dir / f'pip-build-{target_ref}'
175+
git_checkout_dir = tmp_dir / f"pip-build-{target_ref}"
174176
nox_session.run(
175-
'git', 'worktree', 'add', '--force', '--checkout',
177+
# fmt: off
178+
"git", "worktree", "add", "--force", "--checkout",
176179
str(git_checkout_dir), str(target_ref),
177-
external=True, silent=True,
180+
# fmt: on
181+
external=True,
182+
silent=True,
178183
)
179184

180185
try:
181186
yield git_checkout_dir
182187
finally:
183188
nox_session.run(
184-
'git', 'worktree', 'remove', '--force',
185-
str(git_checkout_dir),
186-
external=True, silent=True,
189+
# fmt: off
190+
"git", "worktree", "remove", "--force", str(git_checkout_dir),
191+
# fmt: on
192+
external=True,
193+
silent=True,
187194
)
188195

189196

190197
def get_git_untracked_files() -> Iterator[str]:
191198
"""List all local file paths that aren't tracked by Git."""
192199
git_ls_files_cmd = (
200+
# fmt: off
193201
"git", "ls-files",
194202
"--ignored", "--exclude-standard",
195203
"--others", "--", ".",
204+
# fmt: on
196205
)
197206
# session.run doesn't seem to return any output:
198207
ls_files_out = subprocess.check_output(git_ls_files_cmd, text=True)

tools/tox_pip.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,33 @@
55
from glob import glob
66
from typing import List
77

8-
VIRTUAL_ENV = os.environ['VIRTUAL_ENV']
9-
TOX_PIP_DIR = os.path.join(VIRTUAL_ENV, 'pip')
8+
VIRTUAL_ENV = os.environ["VIRTUAL_ENV"]
9+
TOX_PIP_DIR = os.path.join(VIRTUAL_ENV, "pip")
1010

1111

1212
def pip(args: List[str]) -> None:
1313
# First things first, get a recent (stable) version of pip.
1414
if not os.path.exists(TOX_PIP_DIR):
15-
subprocess.check_call([sys.executable, '-m', 'pip',
16-
'--disable-pip-version-check',
17-
'install', '-t', TOX_PIP_DIR,
18-
'pip'])
19-
shutil.rmtree(glob(os.path.join(TOX_PIP_DIR, 'pip-*.dist-info'))[0])
15+
subprocess.check_call(
16+
[
17+
sys.executable,
18+
"-m",
19+
"pip",
20+
"--disable-pip-version-check",
21+
"install",
22+
"-t",
23+
TOX_PIP_DIR,
24+
"pip",
25+
]
26+
)
27+
shutil.rmtree(glob(os.path.join(TOX_PIP_DIR, "pip-*.dist-info"))[0])
2028
# And use that version.
21-
pypath_env = os.environ.get('PYTHONPATH')
29+
pypath_env = os.environ.get("PYTHONPATH")
2230
pypath = pypath_env.split(os.pathsep) if pypath_env is not None else []
2331
pypath.insert(0, TOX_PIP_DIR)
24-
os.environ['PYTHONPATH'] = os.pathsep.join(pypath)
25-
subprocess.check_call([sys.executable, '-m', 'pip'] + args)
32+
os.environ["PYTHONPATH"] = os.pathsep.join(pypath)
33+
subprocess.check_call([sys.executable, "-m", "pip"] + args)
2634

2735

28-
if __name__ == '__main__':
36+
if __name__ == "__main__":
2937
pip(sys.argv[1:])

0 commit comments

Comments
 (0)