Skip to content

Commit 171e353

Browse files
Merge pull request #391 from jarrodmillman/black
Use black
2 parents 9233a82 + 4b38c01 commit 171e353

20 files changed

+1118
-941
lines changed

.pre-commit-config.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ repos:
1616
- id: check-toml
1717
- id: check-added-large-files
1818

19+
- repo: https://github.com/psf/black
20+
rev: 22.3.0
21+
hooks:
22+
- id: black
23+
1924
- repo: https://github.com/pre-commit/mirrors-prettier
2025
rev: v2.6.2
2126
hooks:

doc/conf.py

+33-29
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
# documentation root, use os.path.abspath to make it absolute, like shown here.
2222

2323
# for example.py
24-
sys.path.insert(0, os.path.abspath('.'))
24+
sys.path.insert(0, os.path.abspath("."))
2525
# project root
26-
sys.path.insert(0, os.path.abspath('..'))
26+
sys.path.insert(0, os.path.abspath(".."))
2727

28-
os.environ['MPLBACKEND'] = 'Agg' # avoid tkinter import errors on rtfd.io
28+
os.environ["MPLBACKEND"] = "Agg" # avoid tkinter import errors on rtfd.io
2929

3030
# -- General configuration ---------------------------------------------------
3131

@@ -36,32 +36,32 @@
3636
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3737
# ones.
3838
extensions = [
39-
'sphinx.ext.autodoc',
40-
'sphinx.ext.autosummary',
41-
'sphinx.ext.doctest',
42-
'sphinx.ext.intersphinx',
43-
'sphinx.ext.todo',
44-
'numpydoc',
45-
'sphinx.ext.ifconfig',
46-
'sphinx.ext.viewcode',
47-
'sphinx.ext.imgmath',
39+
"sphinx.ext.autodoc",
40+
"sphinx.ext.autosummary",
41+
"sphinx.ext.doctest",
42+
"sphinx.ext.intersphinx",
43+
"sphinx.ext.todo",
44+
"numpydoc",
45+
"sphinx.ext.ifconfig",
46+
"sphinx.ext.viewcode",
47+
"sphinx.ext.imgmath",
4848
]
4949

5050
# Add any paths that contain templates here, relative to this directory.
51-
templates_path = ['_templates']
51+
templates_path = ["_templates"]
5252

5353
# The suffix of source filenames.
54-
source_suffix = '.rst'
54+
source_suffix = ".rst"
5555

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

5959
# The root toctree document
60-
master_doc = 'index' # NOTE: will be changed to `root_doc` in sphinx 4
60+
master_doc = "index" # NOTE: will be changed to `root_doc` in sphinx 4
6161

6262
# General information about the project.
63-
project = 'numpydoc'
64-
copyright = f'2019-{date.today().year}, numpydoc maintainers'
63+
project = "numpydoc"
64+
copyright = f"2019-{date.today().year}, numpydoc maintainers"
6565

6666
# The version info for the project you're documenting, acts as replacement for
6767
# |version| and |release|, also used in various other places throughout the
@@ -70,12 +70,13 @@
7070
# The short X.Y version.
7171

7272
import numpydoc
73+
7374
# version = .__version__
7475
# The full version, including alpha/beta/rc tags.
7576
release = numpydoc.__version__
7677
version = numpydoc.__version__
7778
numpydoc_xref_param_type = True
78-
numpydoc_xref_ignore = {'optional', 'type_without_description', 'BadException'}
79+
numpydoc_xref_ignore = {"optional", "type_without_description", "BadException"}
7980
# Run docstring validation as part of build process
8081
numpydoc_validation_checks = {"all", "GL01", "SA04", "RT03"}
8182

@@ -91,7 +92,7 @@
9192

9293
# List of patterns, relative to source directory, that match files and
9394
# directories to ignore when looking for source files.
94-
exclude_patterns = ['_build']
95+
exclude_patterns = ["_build"]
9596

9697
# The reST default role (used for this markup: `text`) to use for all
9798
# documents.
@@ -109,7 +110,7 @@
109110
# show_authors = False
110111

111112
# The name of the Pygments (syntax highlighting) style to use.
112-
pygments_style = 'sphinx'
113+
pygments_style = "sphinx"
113114

114115
# A list of ignored prefixes for module index sorting.
115116
# modindex_common_prefix = []
@@ -134,7 +135,7 @@
134135
}
135136

136137
html_title = f"{project} v{version} Manual"
137-
html_last_updated_fmt = '%b %d, %Y'
138+
html_last_updated_fmt = "%b %d, %Y"
138139

139140
# Add any paths that contain custom static files (such as style sheets) here,
140141
# relative to this directory. They are copied after the builtin static files,
@@ -188,18 +189,16 @@
188189
# html_file_suffix = None
189190

190191
# Output file base name for HTML help builder.
191-
htmlhelp_basename = 'project-templatedoc'
192+
htmlhelp_basename = "project-templatedoc"
192193

193194

194195
# -- Options for LaTeX output ---------------------------------------------
195196

196197
latex_elements = {
197198
# The paper size ('letterpaper' or 'a4paper').
198199
# 'papersize': 'letterpaper',
199-
200200
# The font size ('10pt', '11pt' or '12pt').
201201
# 'pointsize': '10pt',
202-
203202
# Additional stuff for the LaTeX preamble.
204203
# 'preamble': '',
205204
}
@@ -208,8 +207,13 @@
208207
# (source start file, target name, title,
209208
# author, documentclass [howto, manual, or own class]).
210209
latex_documents = [
211-
('index', 'numpydoc.tex', 'numpydoc Documentation',
212-
'Numpydoc maintainers', 'manual'),
210+
(
211+
"index",
212+
"numpydoc.tex",
213+
"numpydoc Documentation",
214+
"Numpydoc maintainers",
215+
"manual",
216+
),
213217
]
214218

215219
# The name of an image file (relative to this directory) to place at the top of
@@ -247,7 +251,7 @@
247251

248252
# Example configuration for intersphinx: refer to the Python standard library.
249253
intersphinx_mapping = {
250-
'python': ('https://docs.python.org/3/', None),
251-
'numpy': ('https://numpy.org/devdocs/', None),
252-
'sklearn': ('https://scikit-learn.org/stable/', None),
254+
"python": ("https://docs.python.org/3/", None),
255+
"numpy": ("https://numpy.org/devdocs/", None),
256+
"sklearn": ("https://scikit-learn.org/stable/", None),
253257
}

doc/example.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
# numpy module itself, unabbreviated.
3535

3636

37-
def foo(var1, var2, *args, long_var_name='hi', only_seldom_used_keyword=0, **kwargs):
37+
def foo(var1, var2, *args, long_var_name="hi", only_seldom_used_keyword=0, **kwargs):
3838
r"""Summarize the function in one line.
3939
4040
Several sentences providing an extended description. Refer to

numpydoc/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def _verify_sphinx_jinja():
2020
if version.parse(sphinx.__version__) <= version.parse("4.0.2"):
2121
if version.parse(jinja2.__version__) >= version.parse("3.1"):
2222
from sphinx.errors import VersionRequirementError
23+
2324
raise VersionRequirementError(
2425
"\n\nSphinx<4.0.2 is incompatible with Jinja2>=3.1.\n"
2526
"If you wish to continue using sphinx<4.0.2 you need to pin "
@@ -32,4 +33,5 @@ def _verify_sphinx_jinja():
3233

3334
def setup(app, *args, **kwargs):
3435
from .numpydoc import setup
36+
3537
return setup(app, *args, **kwargs)

numpydoc/__main__.py

+16-12
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
def render_object(import_path, config=None):
1313
"""Test numpydoc docstring generation for a given object"""
1414
# TODO: Move Validator._load_obj to a better place than validate
15-
print(get_doc_object(Validator._load_obj(import_path),
16-
config=dict(config or [])))
15+
print(get_doc_object(Validator._load_obj(import_path), config=dict(config or [])))
1716
return 0
1817

1918

@@ -22,25 +21,30 @@ def validate_object(import_path):
2221
results = validate(import_path)
2322
for err_code, err_desc in results["errors"]:
2423
exit_status += 1
25-
print(':'.join([import_path, err_code, err_desc]))
24+
print(":".join([import_path, err_code, err_desc]))
2625
return exit_status
2726

2827

29-
if __name__ == '__main__':
28+
if __name__ == "__main__":
3029
ap = argparse.ArgumentParser(description=__doc__)
31-
ap.add_argument('import_path', help='e.g. numpy.ndarray')
30+
ap.add_argument("import_path", help="e.g. numpy.ndarray")
3231

3332
def _parse_config(s):
34-
key, _, value = s.partition('=')
33+
key, _, value = s.partition("=")
3534
value = ast.literal_eval(value)
3635
return key, value
3736

38-
ap.add_argument('-c', '--config', type=_parse_config,
39-
action='append',
40-
help='key=val where val will be parsed by literal_eval, '
41-
'e.g. -c use_plots=True. Multiple -c can be used.')
42-
ap.add_argument('--validate', action='store_true',
43-
help='validate the object and report errors')
37+
ap.add_argument(
38+
"-c",
39+
"--config",
40+
type=_parse_config,
41+
action="append",
42+
help="key=val where val will be parsed by literal_eval, "
43+
"e.g. -c use_plots=True. Multiple -c can be used.",
44+
)
45+
ap.add_argument(
46+
"--validate", action="store_true", help="validate the object and report errors"
47+
)
4448
args = ap.parse_args()
4549

4650
if args.validate:

numpydoc/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.3.2.dev0'
1+
__version__ = "1.3.2.dev0"

0 commit comments

Comments
 (0)