Skip to content

Commit bde1f43

Browse files
authored
Black: run black over all the code base (Part 2) (#11013)
Continues with the idea started in #10619
1 parent 9e2e786 commit bde1f43

File tree

10 files changed

+202
-203
lines changed

10 files changed

+202
-203
lines changed

readthedocs/config/models.py

+11-23
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,11 @@ def __init__(self, **kwargs):
2020
setattr(self, name, kwargs[name])
2121

2222
def as_dict(self):
23-
return {
24-
name: to_dict(getattr(self, name))
25-
for name in self.__slots__
26-
}
23+
return {name: to_dict(getattr(self, name)) for name in self.__slots__}
2724

2825

2926
# TODO: rename this class to `Build`
3027
class BuildWithOs(Base):
31-
3228
__slots__ = ("os", "tools", "jobs", "apt_packages", "commands")
3329

3430
def __init__(self, **kwargs):
@@ -38,8 +34,7 @@ def __init__(self, **kwargs):
3834

3935

4036
class BuildTool(Base):
41-
42-
__slots__ = ('version', 'full_version')
37+
__slots__ = ("version", "full_version")
4338

4439

4540
class BuildJobs(Base):
@@ -76,39 +71,32 @@ class Python(Base):
7671

7772

7873
class PythonInstallRequirements(Base):
79-
80-
__slots__ = ('requirements',)
74+
__slots__ = ("requirements",)
8175

8276

8377
class PythonInstall(Base):
84-
8578
__slots__ = (
86-
'path',
87-
'method',
88-
'extra_requirements',
79+
"path",
80+
"method",
81+
"extra_requirements",
8982
)
9083

9184

9285
class Conda(Base):
93-
94-
__slots__ = ('environment',)
86+
__slots__ = ("environment",)
9587

9688

9789
class Sphinx(Base):
98-
99-
__slots__ = ('builder', 'configuration', 'fail_on_warning')
90+
__slots__ = ("builder", "configuration", "fail_on_warning")
10091

10192

10293
class Mkdocs(Base):
103-
104-
__slots__ = ('configuration', 'fail_on_warning')
94+
__slots__ = ("configuration", "fail_on_warning")
10595

10696

10797
class Submodules(Base):
108-
109-
__slots__ = ('include', 'exclude', 'recursive')
98+
__slots__ = ("include", "exclude", "recursive")
11099

111100

112101
class Search(Base):
113-
114-
__slots__ = ('ranking', 'ignore')
102+
__slots__ = ("ranking", "ignore")

readthedocs/doc_builder/backends/mkdocs.py

+22-22
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class BaseMkdocs(BaseBuilder):
4141
"""Mkdocs builder."""
4242

4343
# The default theme for mkdocs is the 'mkdocs' theme
44-
DEFAULT_THEME_NAME = 'mkdocs'
44+
DEFAULT_THEME_NAME = "mkdocs"
4545

4646
def __init__(self, *args, **kwargs):
4747
super().__init__(*args, **kwargs)
@@ -57,13 +57,13 @@ def __init__(self, *args, **kwargs):
5757
# for these project that were building with MkDocs in the Corporate
5858
# site.
5959
if self.project.has_feature(Feature.MKDOCS_THEME_RTD):
60-
self.DEFAULT_THEME_NAME = 'readthedocs'
60+
self.DEFAULT_THEME_NAME = "readthedocs"
6161
log.warning(
6262
"Project using readthedocs theme as default for MkDocs.",
6363
project_slug=self.project.slug,
6464
)
6565
else:
66-
self.DEFAULT_THEME_NAME = 'mkdocs'
66+
self.DEFAULT_THEME_NAME = "mkdocs"
6767

6868
def get_final_doctype(self):
6969
"""
@@ -119,10 +119,10 @@ def load_yaml_config(self):
119119
except IOError:
120120
raise MkDocsYAMLParseError(MkDocsYAMLParseError.NOT_FOUND)
121121
except yaml.YAMLError as exc:
122-
note = ''
123-
if hasattr(exc, 'problem_mark'):
122+
note = ""
123+
if hasattr(exc, "problem_mark"):
124124
mark = exc.problem_mark
125-
note = ' (line %d, column %d)' % (
125+
note = " (line %d, column %d)" % (
126126
mark.line + 1,
127127
mark.column + 1,
128128
)
@@ -146,7 +146,7 @@ def append_conf(self):
146146
MkDocsYAMLParseError.INVALID_DOCS_DIR_CONFIG,
147147
)
148148

149-
user_config['docs_dir'] = docs_dir
149+
user_config["docs_dir"] = docs_dir
150150
static_url = self.project.proxied_static_path
151151

152152
# Set mkdocs config values.
@@ -201,14 +201,14 @@ def append_conf(self):
201201

202202
# Use Read the Docs' analytics setup rather than mkdocs'
203203
# This supports using RTD's privacy improvements around analytics
204-
user_config['google_analytics'] = None
204+
user_config["google_analytics"] = None
205205

206206
# README: make MkDocs to use ``readthedocs`` theme as default if the
207207
# user didn't specify a specific theme manually
208208
if self.project.has_feature(Feature.MKDOCS_THEME_RTD):
209-
if 'theme' not in user_config:
209+
if "theme" not in user_config:
210210
# mkdocs<0.17 syntax
211-
user_config['theme'] = self.DEFAULT_THEME_NAME
211+
user_config["theme"] = self.DEFAULT_THEME_NAME
212212

213213
# Write the modified mkdocs configuration
214214
with safe_open(self.yaml_file, "w", encoding="utf-8") as f:
@@ -219,7 +219,7 @@ def append_conf(self):
219219

220220
# Write the mkdocs.yml to the build logs
221221
self.run(
222-
'cat',
222+
"cat",
223223
os.path.relpath(self.yaml_file, self.project_path),
224224
cwd=self.project_path,
225225
)
@@ -229,9 +229,9 @@ def generate_rtd_data(self, docs_dir, mkdocs_config):
229229
# Use the analytics code from mkdocs.yml
230230
# if it isn't set already by Read the Docs,
231231
analytics_code = self.version.project.analytics_code
232-
if not analytics_code and mkdocs_config.get('google_analytics'):
232+
if not analytics_code and mkdocs_config.get("google_analytics"):
233233
# http://www.mkdocs.org/user-guide/configuration/#google_analytics
234-
analytics_code = mkdocs_config['google_analytics'][0]
234+
analytics_code = mkdocs_config["google_analytics"][0]
235235

236236
commit = (
237237
self.version.project.vcs_repo(
@@ -271,14 +271,14 @@ def generate_rtd_data(self, docs_dir, mkdocs_config):
271271
"html_theme": readthedocs_data["theme"],
272272
"pagename": None,
273273
}
274-
tmpl = template_loader.get_template('doc_builder/data.js.tmpl')
274+
tmpl = template_loader.get_template("doc_builder/data.js.tmpl")
275275
return tmpl.render(data_ctx)
276276

277277
def build(self):
278278
build_command = [
279-
self.python_env.venv_bin(filename='python'),
280-
'-m',
281-
'mkdocs',
279+
self.python_env.venv_bin(filename="python"),
280+
"-m",
281+
"mkdocs",
282282
self.builder,
283283
"--clean",
284284
"--site-dir",
@@ -287,7 +287,7 @@ def build(self):
287287
os.path.relpath(self.yaml_file, self.project_path),
288288
]
289289
if self.config.mkdocs.fail_on_warning:
290-
build_command.append('--strict')
290+
build_command.append("--strict")
291291
cmd_ret = self.run(
292292
*build_command,
293293
cwd=self.project_path,
@@ -305,19 +305,19 @@ def get_theme_name(self, mkdocs_config):
305305
:see: http://www.mkdocs.org/about/release-notes/#theme-customization-1164
306306
:returns: the name of the theme RTD will use
307307
"""
308-
theme_setting = mkdocs_config.get('theme')
308+
theme_setting = mkdocs_config.get("theme")
309309
if isinstance(theme_setting, dict):
310310
# Full nested theme config (the new configuration)
311-
return theme_setting.get('name') or self.DEFAULT_THEME_NAME
311+
return theme_setting.get("name") or self.DEFAULT_THEME_NAME
312312

313313
if theme_setting:
314314
# A string which is the name of the theme
315315
return theme_setting
316316

317-
theme_dir = mkdocs_config.get('theme_dir')
317+
theme_dir = mkdocs_config.get("theme_dir")
318318
if theme_dir:
319319
# Use the name of the directory in this project's custom theme directory
320-
return theme_dir.rstrip('/').split('/')[-1]
320+
return theme_dir.rstrip("/").split("/")[-1]
321321

322322
return self.DEFAULT_THEME_NAME
323323

readthedocs/doc_builder/config.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ def load_yaml_config(version, readthedocs_yaml_path=None):
3232

3333
def get_default_formats(project):
3434
"""Get a list of the default formats for ``project``."""
35-
formats = ['htmlzip']
35+
formats = ["htmlzip"]
3636
if project.enable_epub_build:
37-
formats += ['epub']
37+
formats += ["epub"]
3838
if project.enable_pdf_build:
39-
formats += ['pdf']
39+
formats += ["pdf"]
4040
return formats

readthedocs/doc_builder/constants.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
"""Doc build constants."""
32

43
import re

0 commit comments

Comments
 (0)