Skip to content

Commit 1d7b1ab

Browse files
committed
Reformat Python code with ruff
1 parent 07a8f01 commit 1d7b1ab

File tree

2 files changed

+122
-106
lines changed

2 files changed

+122
-106
lines changed

noxfile.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# Attribution-ShareAlike license:
44
# http://creativecommons.org/licenses/by-sa/3.0.
55

6-
import shutil
76

87
import nox
98

@@ -19,10 +18,12 @@ def translation(session):
1918
target_dir = "locales"
2019
session.run(
2120
"sphinx-build",
22-
"-b", "gettext", # build gettext-style message catalogs (.pot file)
23-
"-d", session.cache_dir / ".doctrees", # path to put the cache
21+
"-b",
22+
"gettext", # build gettext-style message catalogs (.pot file)
23+
"-d",
24+
session.cache_dir / ".doctrees", # path to put the cache
2425
"source/", # where the rst files are located
25-
target_dir, # where to put the .pot file
26+
target_dir, # where to put the .pot file
2627
)
2728

2829

@@ -45,10 +46,14 @@ def build(session, autobuild=False):
4546
)
4647

4748
session.run(
48-
command, *extra_args,
49-
"-j", "auto", # parallelize the build
50-
"-b", "html", # use HTML builder
51-
"-d", session.cache_dir / ".doctrees", # path to put the cache
49+
command,
50+
*extra_args,
51+
"-j",
52+
"auto", # parallelize the build
53+
"-b",
54+
"html", # use HTML builder
55+
"-d",
56+
session.cache_dir / ".doctrees", # path to put the cache
5257
"-n", # nitpicky warn about all missing references
5358
"-W", # Treat warnings as errors.
5459
*session.posargs,
@@ -74,12 +79,16 @@ def linkcheck(session):
7479
session.install("-r", "requirements.txt")
7580
session.run(
7681
"sphinx-build",
77-
"-b", "linkcheck", # use linkcheck builder
78-
"-d", session.cache_dir / ".doctrees", # path to put the cache
82+
"-b",
83+
"linkcheck", # use linkcheck builder
84+
"-d",
85+
session.cache_dir / ".doctrees", # path to put the cache
7986
"--color",
80-
"-n", "-W", "--keep-going", # be strict
81-
"source", # where the rst files are located
82-
"build", # where to put the check output
87+
"-n",
88+
"-W",
89+
"--keep-going", # be strict
90+
"source", # where the rst files are located
91+
"build", # where to put the check output
8392
)
8493

8594

source/conf.py

Lines changed: 100 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -31,66 +31,66 @@
3131
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3232
# ones.
3333
extensions = [
34-
'sphinx.ext.extlinks',
35-
'sphinx.ext.intersphinx',
36-
'sphinx.ext.todo',
37-
'sphinx_inline_tabs',
38-
'sphinx_copybutton',
39-
'sphinx_toolbox.collapse',
34+
"sphinx.ext.extlinks",
35+
"sphinx.ext.intersphinx",
36+
"sphinx.ext.todo",
37+
"sphinx_inline_tabs",
38+
"sphinx_copybutton",
39+
"sphinx_toolbox.collapse",
4040
]
4141

4242
# config for copy button
4343
copybutton_prompt_text = r">>> |\.\.\. |\$ |> "
4444
copybutton_prompt_is_regexp = True
4545

4646
# Add any paths that contain templates here, relative to this directory.
47-
templates_path = ['_templates']
47+
templates_path = ["_templates"]
4848

4949
# The suffix(es) of source filenames.
5050
# You can specify multiple suffix as a list of string:
5151
#
5252
# source_suffix = ['.rst', '.md']
53-
source_suffix = '.rst'
53+
source_suffix = ".rst"
5454

5555
# The encoding of source files.
5656
#
5757
# source_encoding = 'utf-8-sig'
5858

5959
# The master toctree document.
60-
master_doc = 'index'
60+
master_doc = "index"
6161

6262
# -- Project information -----------------------------------------------------
6363

64-
github_url = 'https://github.com'
65-
github_repo_org = 'pypa'
66-
github_repo_name = 'packaging.python.org'
67-
github_repo_slug = f'{github_repo_org}/{github_repo_name}'
68-
github_repo_url = f'{github_url}/{github_repo_slug}'
69-
github_repo_issues_url = f'{github_url}/{github_repo_slug}/issues'
70-
github_sponsors_url = f'{github_url}/sponsors'
64+
github_url = "https://github.com"
65+
github_repo_org = "pypa"
66+
github_repo_name = "packaging.python.org"
67+
github_repo_slug = f"{github_repo_org}/{github_repo_name}"
68+
github_repo_url = f"{github_url}/{github_repo_slug}"
69+
github_repo_issues_url = f"{github_url}/{github_repo_slug}/issues"
70+
github_sponsors_url = f"{github_url}/sponsors"
7171

7272
# General information about the project.
73-
project = u'Python Packaging User Guide'
74-
copyright = u'2013–2020, PyPA'
75-
author = 'Python Packaging Authority'
73+
project = "Python Packaging User Guide"
74+
copyright = "2013–2020, PyPA"
75+
author = "Python Packaging Authority"
7676

7777
# The version info for the project you're documenting, acts as replacement for
7878
# |version| and |release|, also used in various other places throughout the
7979
# built documents.
8080
#
8181
# The short X.Y version.
82-
version = ''
82+
version = ""
8383
# The full version, including alpha/beta/rc tags.
84-
release = ''
84+
release = ""
8585

8686
# The language for content autogenerated by Sphinx. Refer to documentation
8787
# for a list of supported languages.
8888
#
8989
# This is also used if you do content translation via gettext catalogs.
9090
# Usually you set "language" from the command line for these cases.
91-
language = 'en'
91+
language = "en"
9292

93-
locale_dirs = ['../locales']
93+
locale_dirs = ["../locales"]
9494

9595
gettext_auto_build = True # Build MO files from PO on each build
9696

@@ -111,12 +111,12 @@
111111
# List of patterns, relative to source directory, that match files and
112112
# directories to ignore when looking for source files.
113113
# This patterns also effect to html_static_path and html_extra_path
114-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
114+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
115115

116116
# The reST default role (used for this markup: `text`) to use for all
117117
# documents.
118118
# Ref: python-attrs/attrs#571
119-
default_role = 'any' # makes single backticks autofind targets
119+
default_role = "any" # makes single backticks autofind targets
120120

121121
# If true, '()' will be appended to :func: etc. cross-reference text.
122122
#
@@ -133,7 +133,7 @@
133133
# show_authors = False
134134

135135
# The name of the Pygments (syntax highlighting) style to use.
136-
#pygments_style = 'sphinx'
136+
# pygments_style = 'sphinx'
137137

138138
# A list of ignored prefixes for module index sorting.
139139
# modindex_common_prefix = []
@@ -150,7 +150,7 @@
150150
# The theme to use for HTML and HTML Help pages. See the documentation for
151151
# a list of builtin themes.
152152
#
153-
html_theme = 'furo'
153+
html_theme = "furo"
154154

155155
# Theme options are theme-specific and customize the look and feel of a theme
156156
# further. For a list of options available for each theme, see the
@@ -166,7 +166,7 @@
166166
# The name for this set of Sphinx documents.
167167
# "<project> v<release> documentation" by default.
168168
#
169-
html_title = 'Python Packaging User Guide'
169+
html_title = "Python Packaging User Guide"
170170

171171
# A shorter title for the navigation bar. Default is the same as html_title.
172172
#
@@ -181,7 +181,7 @@
181181
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
182182
# pixels large.
183183
#
184-
html_favicon = 'assets/py.png'
184+
html_favicon = "assets/py.png"
185185

186186
# Add any paths that contain custom static files (such as style sheets) here,
187187
# relative to this directory. They are copied after the builtin static files,
@@ -198,7 +198,7 @@
198198
# bottom, using the given strftime format.
199199
# The empty string is equivalent to '%b %d, %Y'.
200200
#
201-
html_last_updated_fmt = ''
201+
html_last_updated_fmt = ""
202202

203203
# If true, SmartyPants will be used to convert quotes and dashes to
204204
# typographically correct entities.
@@ -271,34 +271,36 @@
271271
# html_search_scorer = 'scorer.js'
272272

273273
# Output file base name for HTML help builder.
274-
htmlhelp_basename = 'pythonpackagingguide-authdoc'
274+
htmlhelp_basename = "pythonpackagingguide-authdoc"
275275

276276
# -- Options for LaTeX output ---------------------------------------------
277277

278278
latex_elements = {
279-
# The paper size ('letterpaper' or 'a4paper').
280-
#
281-
# 'papersize': 'letterpaper',
282-
283-
# The font size ('10pt', '11pt' or '12pt').
284-
#
285-
# 'pointsize': '10pt',
286-
287-
# Additional stuff for the LaTeX preamble.
288-
#
289-
# 'preamble': '',
290-
291-
# Latex figure (float) alignment
292-
#
293-
# 'figure_align': 'htbp',
279+
# The paper size ('letterpaper' or 'a4paper').
280+
#
281+
# 'papersize': 'letterpaper',
282+
# The font size ('10pt', '11pt' or '12pt').
283+
#
284+
# 'pointsize': '10pt',
285+
# Additional stuff for the LaTeX preamble.
286+
#
287+
# 'preamble': '',
288+
# Latex figure (float) alignment
289+
#
290+
# 'figure_align': 'htbp',
294291
}
295292

296293
# Grouping the document tree into LaTeX files. List of tuples
297294
# (source start file, target name, title,
298295
# author, documentclass [howto, manual, or own class]).
299296
latex_documents = [
300-
(master_doc, 'pythonpackagingguide.tex', 'Python Packaging User Guide',
301-
'Python Packaging Authority', 'manual'),
297+
(
298+
master_doc,
299+
"pythonpackagingguide.tex",
300+
"Python Packaging User Guide",
301+
"Python Packaging Authority",
302+
"manual",
303+
),
302304
]
303305

304306
# The name of an image file (relative to this directory) to place at the top of
@@ -339,8 +341,7 @@
339341
# One entry per manual page. List of tuples
340342
# (source start file, name, description, authors, manual section).
341343
man_pages = [
342-
(master_doc, 'pythonpackagingguide', 'Python Packaging User Guide',
343-
[author], 1)
344+
(master_doc, "pythonpackagingguide", "Python Packaging User Guide", [author], 1)
344345
]
345346

346347
# If true, show URL addresses after external links.
@@ -354,9 +355,15 @@
354355
# (source start file, target name, title, author,
355356
# dir menu entry, description, category)
356357
texinfo_documents = [
357-
(master_doc, 'pythonpackagingguide', 'Python Packaging User Guide',
358-
author, 'pythonpackagingguide', 'One line description of project.',
359-
'Miscellaneous'),
358+
(
359+
master_doc,
360+
"pythonpackagingguide",
361+
"Python Packaging User Guide",
362+
author,
363+
"pythonpackagingguide",
364+
"One line description of project.",
365+
"Miscellaneous",
366+
),
360367
]
361368

362369
# Documents to append as an appendix to all manuals.
@@ -377,11 +384,11 @@
377384

378385
# -- Options for extlinks extension ---------------------------------------
379386
extlinks = {
380-
'issue': (f'{github_repo_issues_url}/%s', '#%s'), # noqa: WPS323
381-
'pr': (f'{github_repo_url}/pull/%s', 'PR #%s'), # noqa: WPS323
382-
'commit': (f'{github_repo_url}/commit/%s', '%s'), # noqa: WPS323
383-
'gh': (f'{github_url}/%s', 'GitHub: %s'), # noqa: WPS323
384-
'user': (f'{github_sponsors_url}/%s', '@%s'), # noqa: WPS323
387+
"issue": (f"{github_repo_issues_url}/%s", "#%s"), # noqa: WPS323
388+
"pr": (f"{github_repo_url}/pull/%s", "PR #%s"), # noqa: WPS323
389+
"commit": (f"{github_repo_url}/commit/%s", "%s"), # noqa: WPS323
390+
"gh": (f"{github_url}/%s", "GitHub: %s"), # noqa: WPS323
391+
"user": (f"{github_sponsors_url}/%s", "@%s"), # noqa: WPS323
385392
}
386393

387394
linkcheck_ignore = [
@@ -395,33 +402,33 @@
395402

396403
# Example configuration for intersphinx: refer to the Python standard library.
397404
intersphinx_mapping = {
398-
'boltons': ('https://boltons.readthedocs.io/en/latest/', None),
399-
'bottle': ('https://bottlepy.org/docs/dev/', None),
400-
'build': ('https://pypa-build.readthedocs.io/en/stable/', None),
401-
'cffi': ('https://cffi.readthedocs.io/en/latest/', None),
402-
'conda': ('https://conda.io/en/latest/', None),
403-
'devpi': ('https://devpi.net/docs/devpi/devpi/latest/+doc', None),
404-
'dh-virtualenv': ('https://dh-virtualenv.readthedocs.io/en/latest/', None),
405-
'distlib': ('https://distlib.readthedocs.io/en/latest/', None),
406-
'flexx': ('https://flexx.readthedocs.io/en/latest/', None),
407-
'nox': ('https://nox.thea.codes/en/latest/', None),
408-
'openstack': ('https://docs.openstack.org/glance/latest/', None),
409-
'packaging': ('https://packaging.pypa.io/en/latest/', None),
410-
'packaging.python.org': ('https://packaging.python.org/en/latest/', None),
411-
'pip': ('https://pip.pypa.io/en/latest/', None),
412-
'pipenv': ('https://pipenv.pypa.io/en/latest/', None),
413-
'piwheels': ('https://piwheels.readthedocs.io/en/latest/', None),
414-
'pybind11': ('https://pybind11.readthedocs.io/en/stable/', None),
415-
'pynsist': ('https://pynsist.readthedocs.io/en/latest/', None),
416-
'pypa': ('https://www.pypa.io/en/latest/', None),
417-
'python': ('https://docs.python.org/3', None),
418-
'python-guide': ('https://docs.python-guide.org', None),
419-
'setuptools': ('https://setuptools.pypa.io/en/latest/', None),
420-
'spack': ('https://spack.readthedocs.io/en/latest/', None),
421-
'sphinx': ('https://www.sphinx-doc.org/en/master', None),
422-
'tox': ('https://tox.wiki/en/latest/', None),
423-
'twine': ('https://twine.readthedocs.io/en/stable/', None),
424-
'virtualenv': ('https://virtualenv.pypa.io/en/stable/', None),
405+
"boltons": ("https://boltons.readthedocs.io/en/latest/", None),
406+
"bottle": ("https://bottlepy.org/docs/dev/", None),
407+
"build": ("https://pypa-build.readthedocs.io/en/stable/", None),
408+
"cffi": ("https://cffi.readthedocs.io/en/latest/", None),
409+
"conda": ("https://conda.io/en/latest/", None),
410+
"devpi": ("https://devpi.net/docs/devpi/devpi/latest/+doc", None),
411+
"dh-virtualenv": ("https://dh-virtualenv.readthedocs.io/en/latest/", None),
412+
"distlib": ("https://distlib.readthedocs.io/en/latest/", None),
413+
"flexx": ("https://flexx.readthedocs.io/en/latest/", None),
414+
"nox": ("https://nox.thea.codes/en/latest/", None),
415+
"openstack": ("https://docs.openstack.org/glance/latest/", None),
416+
"packaging": ("https://packaging.pypa.io/en/latest/", None),
417+
"packaging.python.org": ("https://packaging.python.org/en/latest/", None),
418+
"pip": ("https://pip.pypa.io/en/latest/", None),
419+
"pipenv": ("https://pipenv.pypa.io/en/latest/", None),
420+
"piwheels": ("https://piwheels.readthedocs.io/en/latest/", None),
421+
"pybind11": ("https://pybind11.readthedocs.io/en/stable/", None),
422+
"pynsist": ("https://pynsist.readthedocs.io/en/latest/", None),
423+
"pypa": ("https://www.pypa.io/en/latest/", None),
424+
"python": ("https://docs.python.org/3", None),
425+
"python-guide": ("https://docs.python-guide.org", None),
426+
"setuptools": ("https://setuptools.pypa.io/en/latest/", None),
427+
"spack": ("https://spack.readthedocs.io/en/latest/", None),
428+
"sphinx": ("https://www.sphinx-doc.org/en/master", None),
429+
"tox": ("https://tox.wiki/en/latest/", None),
430+
"twine": ("https://twine.readthedocs.io/en/stable/", None),
431+
"virtualenv": ("https://virtualenv.pypa.io/en/stable/", None),
425432
}
426433

427434

@@ -435,12 +442,12 @@
435442
# NOTE: consider having a separate ignore file
436443
# Ref: https://stackoverflow.com/a/30624034/595220
437444
nitpick_ignore = [
438-
('envvar', 'PATH'),
439-
('py:func', 'find_packages'),
440-
('py:func', 'setup'),
441-
('py:func', 'importlib.metadata.entry_points'), # remove when 3.10 is released
442-
('py:class', 'importlib.metadata.EntryPoint'), # remove when 3.10 is released
443-
('py:func', 'setuptools.find_namespace_packages'),
444-
('py:func', 'setuptools.find_packages'),
445-
('py:func', 'setuptools.setup'),
445+
("envvar", "PATH"),
446+
("py:func", "find_packages"),
447+
("py:func", "setup"),
448+
("py:func", "importlib.metadata.entry_points"), # remove when 3.10 is released
449+
("py:class", "importlib.metadata.EntryPoint"), # remove when 3.10 is released
450+
("py:func", "setuptools.find_namespace_packages"),
451+
("py:func", "setuptools.find_packages"),
452+
("py:func", "setuptools.setup"),
446453
]

0 commit comments

Comments
 (0)