Skip to content

Commit 9da455f

Browse files
committed
Force single quotes with ruff
1 parent d6af52c commit 9da455f

File tree

8 files changed

+42
-43
lines changed

8 files changed

+42
-43
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@ repos:
33
rev: v0.8.4
44
hooks:
55
- id: ruff
6-
args: [--exit-non-zero-on-fix]
7-
8-
- repo: https://github.com/psf/black-pre-commit-mirror
9-
rev: 24.10.0
10-
hooks:
11-
- id: black
6+
args: [--fix, --exit-non-zero-on-fix]
7+
- id: ruff-format
128

139
- repo: https://github.com/pre-commit/pre-commit-hooks
1410
rev: v5.0.0

completion.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@
1111

1212
@cache
1313
def branches_from_devguide(devguide_dir: Path) -> list[str]:
14-
p = devguide_dir.joinpath("include/release-cycle.json")
14+
p = devguide_dir.joinpath('include/release-cycle.json')
1515
data = json.loads(p.read_text())
1616
return [
17-
branch for branch in data if data[branch]["status"] in ("bugfix", "security")
17+
branch for branch in data if data[branch]['status'] in ('bugfix', 'security')
1818
]
1919

2020

2121
def get_completion(clones_dir: str, repo: str) -> tuple[float, int]:
2222
clone_path = Path(clones_dir, repo)
23-
for branch in branches_from_devguide(Path(clones_dir, "devguide")) + ["master"]:
23+
for branch in branches_from_devguide(Path(clones_dir, 'devguide')) + ['master']:
2424
try:
2525
git.Repo.clone_from(
26-
f"https://github.com/{repo}.git", clone_path, branch=branch
26+
f'https://github.com/{repo}.git', clone_path, branch=branch
2727
)
2828
except git.GitCommandError:
29-
print(f"failed to clone {repo} {branch}")
29+
print(f'failed to clone {repo} {branch}')
3030
translators_number = 0
3131
continue
3232
else:
@@ -35,9 +35,9 @@ def get_completion(clones_dir: str, repo: str) -> tuple[float, int]:
3535
with TemporaryDirectory() as tmpdir:
3636
completion = potodo.merge_and_scan_path(
3737
clone_path,
38-
pot_path=Path(clones_dir, "cpython/Doc/build/gettext"),
38+
pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'),
3939
merge_path=Path(tmpdir),
4040
hide_reserved=False,
41-
api_url="",
41+
api_url='',
4242
).completion
4343
return completion, translators_number

generate.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@
2626

2727
with TemporaryDirectory() as clones_dir:
2828
Repo.clone_from(
29-
"https://github.com/python/devguide.git",
30-
devguide_dir := Path(clones_dir, "devguide"),
29+
'https://github.com/python/devguide.git',
30+
devguide_dir := Path(clones_dir, 'devguide'),
3131
depth=1,
3232
)
3333
latest_branch = branches_from_devguide(devguide_dir)[0]
3434
Repo.clone_from(
35-
"https://github.com/python/cpython.git",
36-
Path(clones_dir, "cpython"),
35+
'https://github.com/python/cpython.git',
36+
Path(clones_dir, 'cpython'),
3737
depth=1,
3838
branch=latest_branch,
3939
)
40-
subprocess.run(["make", "-C", Path(clones_dir, "cpython/Doc"), "venv"], check=True)
40+
subprocess.run(['make', '-C', Path(clones_dir, 'cpython/Doc'), 'venv'], check=True)
4141
subprocess.run(
42-
["make", "-C", Path(clones_dir, "cpython/Doc"), "gettext"], check=True
42+
['make', '-C', Path(clones_dir, 'cpython/Doc'), 'gettext'], check=True
4343
)
4444
switcher_languages = list(switcher.get_languages())
4545
for language, repo in repositories.get_languages_and_repos(devguide_dir):
@@ -124,5 +124,5 @@
124124
completion_progress=completion_progress, generation_time=generation_time
125125
)
126126

127-
with open("index.html", "w") as file:
127+
with open('index.html', 'w') as file:
128128
file.write(output)

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[tool.ruff.format]
2+
quote-style = "single"

repositories.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
def get_languages_and_repos(
1010
devguide_dir: pathlib.Path,
1111
) -> Generator[tuple[str, Optional[str]], None, None]:
12-
translating = devguide_dir.joinpath("documentation/translating.rst").read_text()
12+
translating = devguide_dir.joinpath('documentation/translating.rst').read_text()
1313
doctree = core.publish_doctree(translating)
1414

1515
for node in doctree.traverse(table):
1616
for row_node in node.traverse(row)[1:]:
1717
language = row_node[0].astext()
1818
repo = row_node[2].astext()
1919
language_code = (
20-
re.match(r".* \((.*)\)", language).group(1).lower().replace("_", "-")
20+
re.match(r'.* \((.*)\)', language).group(1).lower().replace('_', '-')
2121
)
22-
repo_match = re.match(":github:`GitHub <(.*)>`", repo)
22+
repo_match = re.match(':github:`GitHub <(.*)>`', repo)
2323
yield language_code, repo_match and repo_match.group(1)

switcher.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@
1313

1414
def get_languages() -> Generator[str, None, None]:
1515
data = requests.get(
16-
"https://raw.githubusercontent.com/"
17-
"python/docsbuild-scripts/refs/heads/main/config.toml",
16+
'https://raw.githubusercontent.com/'
17+
'python/docsbuild-scripts/refs/heads/main/config.toml',
1818
timeout=10,
1919
).text
2020
config = tomllib.loads(data)
21-
languages = config["languages"]
22-
defaults = config["defaults"]
21+
languages = config['languages']
22+
defaults = config['defaults']
2323
for code, language in languages.items():
24-
if language.get("in_prod", defaults["in_prod"]):
25-
yield code.lower().replace("_", "-")
24+
if language.get('in_prod', defaults['in_prod']):
25+
yield code.lower().replace('_', '-')
2626

2727

2828
def main() -> None:
2929
languages = list(get_languages())
3030
print(languages)
31-
for code in ("en", "pl", "ar", "zh-cn"):
32-
print(f"{code}: {code in languages}")
31+
for code in ('en', 'pl', 'ar', 'zh-cn'):
32+
print(f'{code}: {code in languages}')
3333

3434

35-
if __name__ == "__main__":
35+
if __name__ == '__main__':
3636
main()

translators.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ def get_number(path: Path) -> int:
1212

1313

1414
def get_number_from_git_history(path: Path) -> int:
15-
return len(Repo(path).git.shortlog("-s", "HEAD").splitlines())
15+
return len(Repo(path).git.shortlog('-s', 'HEAD').splitlines())
1616

1717

1818
def yield_from_headers(path: Path) -> Generator[str, None, None]:
19-
for file in path.rglob("*.po"):
19+
for file in path.rglob('*.po'):
2020
try:
2121
header = pofile(file).header.splitlines()
2222
except IOError:
2323
continue
24-
if "Translators:" not in header:
24+
if 'Translators:' not in header:
2525
continue
26-
for translator_record in header[header.index("Translators:") + 1 :]:
26+
for translator_record in header[header.index('Translators:') + 1 :]:
2727
try:
28-
translator, _year = translator_record.split(", ")
28+
translator, _year = translator_record.split(', ')
2929
except ValueError:
3030
yield translator_record
3131
else:

visitors.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88

99
def get_number_of_visitors(language: str) -> int:
1010
param = urllib.parse.urlencode(
11-
{"filters": f'[["contains","event:page",["/{language}/"]]]'}
11+
{'filters': f'[["contains","event:page",["/{language}/"]]]'}
1212
)
13-
r = requests.get(f"https://plausible.io/docs.python.org/export?{param}", timeout=10)
14-
with zipfile.ZipFile(io.BytesIO(r.content), "r") as z, z.open(
15-
"visitors.csv"
16-
) as csv_file:
13+
r = requests.get(f'https://plausible.io/docs.python.org/export?{param}', timeout=10)
14+
with (
15+
zipfile.ZipFile(io.BytesIO(r.content), 'r') as z,
16+
z.open('visitors.csv') as csv_file,
17+
):
1718
csv_reader = csv.DictReader(io.TextIOWrapper(csv_file))
18-
return sum(int(row["visitors"]) for row in csv_reader)
19+
return sum(int(row['visitors']) for row in csv_reader)

0 commit comments

Comments
 (0)