Skip to content

Commit 3edf2a2

Browse files
committed
Style sphinx.ext.intersphinx
1 parent 14c1bc7 commit 3edf2a2

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

sphinx/ext/intersphinx/_cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
def inspect_main(argv: list[str], /) -> int:
1111
"""Debug functionality to print out an inventory"""
1212
if len(argv) < 1:
13-
print("Print out an inventory file.\n"
14-
"Error: must specify local path or URL to an inventory file.",
13+
print('Print out an inventory file.\n'
14+
'Error: must specify local path or URL to an inventory file.',
1515
file=sys.stderr)
1616
return 1
1717

sphinx/ext/intersphinx/_load.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ def normalize_intersphinx_mapping(app: Sphinx, config: Config) -> None:
4242
name, uri, inv = None, key, value
4343
msg = (
4444
"The pre-Sphinx 1.0 'intersphinx_mapping' format is "
45-
"deprecated and will be removed in Sphinx 8. Update to the "
46-
"current format as described in the documentation. "
47-
f"Hint: \"intersphinx_mapping = {{'<name>': {(uri, inv)!r}}}\"."
48-
"https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html#confval-intersphinx_mapping" # NoQA: E501
45+
'deprecated and will be removed in Sphinx 8. Update to the '
46+
'current format as described in the documentation. '
47+
f"Hint: `intersphinx_mapping = {{'<name>': {(uri, inv)!r}}}`."
48+
'https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html#confval-intersphinx_mapping' # NoQA: E501
4949
)
5050
LOGGER.warning(msg)
5151

@@ -131,14 +131,14 @@ def fetch_inventory_group(
131131
if failures == []:
132132
pass
133133
elif len(failures) < len(invs):
134-
LOGGER.info(__("encountered some issues with some of the inventories,"
135-
" but they had working alternatives:"))
134+
LOGGER.info(__('encountered some issues with some of the inventories,'
135+
' but they had working alternatives:'))
136136
for fail in failures:
137137
LOGGER.info(*fail)
138138
else:
139139
issues = '\n'.join(f[0] % f[1:] for f in failures)
140-
LOGGER.warning(__("failed to reach any of the inventories "
141-
"with the following issues:") + "\n" + issues)
140+
LOGGER.warning(__('failed to reach any of the inventories '
141+
'with the following issues:') + '\n' + issues)
142142

143143

144144
def fetch_inventory(app: Sphinx, uri: str, inv: str) -> Inventory:
@@ -218,7 +218,7 @@ def _strip_basic_auth(url: str) -> str:
218218
:rtype: ``str``
219219
"""
220220
frags = list(urlsplit(url))
221-
# swap out "user[:pass]@hostname" for "hostname"
221+
# swap out 'user[:pass]@hostname' for 'hostname'
222222
if '@' in frags[1]:
223223
frags[1] = frags[1].split('@')[1]
224224
return urlunsplit(frags)

sphinx/ext/intersphinx/_resolve.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ def _create_element_from_result(domain: Domain, inv_name: str | None,
4646
if node.get('refexplicit'):
4747
# use whatever title was given
4848
newnode.append(contnode)
49-
elif dispname == '-' or \
50-
(domain.name == 'std' and node['reftype'] == 'keyword'):
49+
elif dispname == '-' or (domain.name == 'std' and node['reftype'] == 'keyword'):
5150
# use whatever title was given, but strip prefix
5251
title = contnode.astext()
5352
if inv_name is not None and title.startswith(inv_name + ':'):
@@ -113,7 +112,7 @@ def _resolve_reference_in_domain(env: BuildEnvironment,
113112

114113
# the inventory contains domain:type as objtype
115114
domain_name = domain.name
116-
obj_types = {f"{domain_name}:{obj_type}": None for obj_type in obj_types}
115+
obj_types = {f'{domain_name}:{obj_type}': None for obj_type in obj_types}
117116

118117
# now that the objtypes list is complete we can remove the disabled ones
119118
if honor_disabled_refs:
@@ -151,7 +150,7 @@ def _resolve_reference(env: BuildEnvironment, inv_name: str | None, inventory: I
151150
if typ == 'any':
152151
for domain_name, domain in env.domains.items():
153152
if (honor_disabled_refs
154-
and (domain_name + ":*") in env.config.intersphinx_disabled_reftypes):
153+
and (domain_name + ':*') in env.config.intersphinx_disabled_reftypes):
155154
continue
156155
objtypes: Iterable[str] = domain.object_types.keys()
157156
res = _resolve_reference_in_domain(env, inv_name, inventory,
@@ -166,8 +165,8 @@ def _resolve_reference(env: BuildEnvironment, inv_name: str | None, inventory: I
166165
if not domain_name:
167166
# only objects in domains are in the inventory
168167
return None
169-
if honor_disabled_refs \
170-
and (domain_name + ":*") in env.config.intersphinx_disabled_reftypes:
168+
if (honor_disabled_refs
169+
and (domain_name + ':*') in env.config.intersphinx_disabled_reftypes):
171170
return None
172171
domain = env.get_domain(domain_name)
173172
objtypes = domain.objtypes_for_role(typ) or ()
@@ -264,7 +263,7 @@ class IntersphinxRole(SphinxRole):
264263
# group 1: just for the optionality of the inventory name
265264
# group 2: the inventory name (optional)
266265
# group 3: the domain:role or role part
267-
_re_inv_ref = re.compile(r"(\+([^:]+))?:(.*)")
266+
_re_inv_ref = re.compile(r'(\+([^:]+))?:(.*)')
268267

269268
def __init__(self, orig_name: str) -> None:
270269
self.orig_name = orig_name

0 commit comments

Comments
 (0)