Skip to content

Commit 77a363b

Browse files
authored
Add Ruff configuration file (#262)
1 parent 6d53796 commit 77a363b

File tree

4 files changed

+76
-86
lines changed

4 files changed

+76
-86
lines changed

Diff for: .pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ repos:
1414
- id: trailing-whitespace
1515

1616
- repo: https://github.com/astral-sh/ruff-pre-commit
17-
rev: v0.9.6
17+
rev: v0.11.5
1818
hooks:
1919
- id: ruff-format
2020

Diff for: .ruff.toml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
target-version = "py313" # Pin Ruff to Python 3.13
2+
line-length = 88
3+
output-format = "full"
4+
5+
[format]
6+
preview = true
7+
docstring-code-format = true

Diff for: build_docs.py

+64-79
Original file line numberDiff line numberDiff line change
@@ -608,14 +608,12 @@ def build(self):
608608
sphinxopts = list(self.language.sphinxopts)
609609
if self.language.tag != "en":
610610
locale_dirs = self.build_root / self.version.name / "locale"
611-
sphinxopts.extend(
612-
(
613-
f"-D locale_dirs={locale_dirs}",
614-
f"-D language={self.language.iso639_tag}",
615-
"-D gettext_compact=0",
616-
"-D translation_progress_classes=1",
617-
)
618-
)
611+
sphinxopts.extend((
612+
f"-D locale_dirs={locale_dirs}",
613+
f"-D language={self.language.iso639_tag}",
614+
"-D gettext_compact=0",
615+
"-D translation_progress_classes=1",
616+
))
619617
if self.language.tag == "ja":
620618
# Since luatex doesn't support \ufffd, replace \ufffd with '?'.
621619
# https://gist.github.com/zr-tex8r/e0931df922f38fbb67634f05dfdaf66b
@@ -667,20 +665,18 @@ def build(self):
667665
self.version,
668666
self.checkout / "Doc" / "tools" / "templates" / "indexsidebar.html",
669667
)
670-
run_with_logging(
671-
[
672-
"make",
673-
"-C",
674-
self.checkout / "Doc",
675-
"PYTHON=" + str(python),
676-
"SPHINXBUILD=" + str(sphinxbuild),
677-
"BLURB=" + str(blurb),
678-
"VENVDIR=" + str(self.venv),
679-
"SPHINXOPTS=" + " ".join(sphinxopts),
680-
"SPHINXERRORHANDLING=",
681-
maketarget,
682-
]
683-
)
668+
run_with_logging([
669+
"make",
670+
"-C",
671+
self.checkout / "Doc",
672+
"PYTHON=" + str(python),
673+
"SPHINXBUILD=" + str(sphinxbuild),
674+
"BLURB=" + str(blurb),
675+
"VENVDIR=" + str(self.venv),
676+
"SPHINXOPTS=" + " ".join(sphinxopts),
677+
"SPHINXERRORHANDLING=",
678+
maketarget,
679+
])
684680
run(["mkdir", "-p", self.log_directory])
685681
run(["chgrp", "-R", self.group, self.log_directory])
686682
if self.includes_html:
@@ -743,69 +739,57 @@ def copy_build_to_webroot(self, http: urllib3.PoolManager) -> None:
743739
# Copy built HTML files to webroot (default /srv/docs.python.org)
744740
changed = changed_files(self.checkout / "Doc" / "build" / "html", target)
745741
logging.info("Copying HTML files to %s", target)
746-
run(
747-
[
748-
"chown",
749-
"-R",
750-
":" + self.group,
751-
self.checkout / "Doc" / "build" / "html/",
752-
]
753-
)
742+
run([
743+
"chown",
744+
"-R",
745+
":" + self.group,
746+
self.checkout / "Doc" / "build" / "html/",
747+
])
754748
run(["chmod", "-R", "o+r", self.checkout / "Doc" / "build" / "html"])
755-
run(
756-
[
757-
"find",
758-
self.checkout / "Doc" / "build" / "html",
759-
"-type",
760-
"d",
761-
"-exec",
762-
"chmod",
763-
"o+x",
764-
"{}",
765-
";",
766-
]
767-
)
768-
run(
769-
[
770-
"rsync",
771-
"-a",
772-
"--delete-delay",
773-
"--filter",
774-
"P archives/",
775-
str(self.checkout / "Doc" / "build" / "html") + "/",
776-
target,
777-
]
778-
)
749+
run([
750+
"find",
751+
self.checkout / "Doc" / "build" / "html",
752+
"-type",
753+
"d",
754+
"-exec",
755+
"chmod",
756+
"o+x",
757+
"{}",
758+
";",
759+
])
760+
run([
761+
"rsync",
762+
"-a",
763+
"--delete-delay",
764+
"--filter",
765+
"P archives/",
766+
str(self.checkout / "Doc" / "build" / "html") + "/",
767+
target,
768+
])
779769

780770
if not self.quick:
781771
# Copy archive files to /archives/
782772
logging.debug("Copying dist files.")
783-
run(
784-
[
785-
"chown",
786-
"-R",
787-
":" + self.group,
788-
self.checkout / "Doc" / "dist",
789-
]
790-
)
791-
run(
792-
[
793-
"chmod",
794-
"-R",
795-
"o+r",
796-
self.checkout / "Doc" / "dist",
797-
]
798-
)
773+
run([
774+
"chown",
775+
"-R",
776+
":" + self.group,
777+
self.checkout / "Doc" / "dist",
778+
])
779+
run([
780+
"chmod",
781+
"-R",
782+
"o+r",
783+
self.checkout / "Doc" / "dist",
784+
])
799785
run(["mkdir", "-m", "o+rx", "-p", target / "archives"])
800786
run(["chown", ":" + self.group, target / "archives"])
801-
run(
802-
[
803-
"cp",
804-
"-a",
805-
*(self.checkout / "Doc" / "dist").glob("*"),
806-
target / "archives",
807-
]
808-
)
787+
run([
788+
"cp",
789+
"-a",
790+
*(self.checkout / "Doc" / "dist").glob("*"),
791+
target / "archives",
792+
])
809793
changed.append("archives/")
810794
for file in (target / "archives").iterdir():
811795
changed.append("archives/" + file.name)
@@ -984,7 +968,8 @@ def parse_args():
984968
default=Path("/var/log/docsbuild/"),
985969
)
986970
parser.add_argument(
987-
"--languages", "--language",
971+
"--languages",
972+
"--language",
988973
nargs="*",
989974
help="Language translation, as a PEP 545 language tag like"
990975
" 'fr' or 'pt-br'. "

Diff for: check_versions.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,10 @@ async def which_sphinx_is_used_in_production():
111111
table = [
112112
[
113113
version.name,
114-
*await asyncio.gather(
115-
*[
116-
get_version_in_prod(language.tag, version.name)
117-
for language in LANGUAGES
118-
]
119-
),
114+
*await asyncio.gather(*[
115+
get_version_in_prod(language.tag, version.name)
116+
for language in LANGUAGES
117+
]),
120118
]
121119
for version in VERSIONS
122120
]

0 commit comments

Comments
 (0)