Skip to content

Commit

Permalink
Style sphinx.ext.intersphinx
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Apr 25, 2024
1 parent 4f18cd3 commit 88c2782
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
4 changes: 2 additions & 2 deletions sphinx/ext/intersphinx/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
def inspect_main(argv: list[str], /) -> int:
"""Debug functionality to print out an inventory"""
if len(argv) < 1:
print("Print out an inventory file.\n"
"Error: must specify local path or URL to an inventory file.",
print('Print out an inventory file.\n'
'Error: must specify local path or URL to an inventory file.',
file=sys.stderr)
return 1

Expand Down
18 changes: 9 additions & 9 deletions sphinx/ext/intersphinx/_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ def normalize_intersphinx_mapping(app: Sphinx, config: Config) -> None:
name, uri, inv = None, key, value
msg = (
"The pre-Sphinx 1.0 'intersphinx_mapping' format is "
"deprecated and will be removed in Sphinx 8. Update to the "
"current format as described in the documentation. "
f"Hint: \"intersphinx_mapping = {{'<name>': {(uri, inv)!r}}}\"."
"https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html#confval-intersphinx_mapping" # NoQA: E501
'deprecated and will be removed in Sphinx 8. Update to the '
'current format as described in the documentation. '
f"Hint: `intersphinx_mapping = {{'<name>': {(uri, inv)!r}}}`."
'https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html#confval-intersphinx_mapping' # NoQA: E501
)
LOGGER.warning(msg)

Expand Down Expand Up @@ -131,14 +131,14 @@ def fetch_inventory_group(
if failures == []:
pass
elif len(failures) < len(invs):
LOGGER.info(__("encountered some issues with some of the inventories,"
" but they had working alternatives:"))
LOGGER.info(__('encountered some issues with some of the inventories,'
' but they had working alternatives:'))
for fail in failures:
LOGGER.info(*fail)
else:
issues = '\n'.join(f[0] % f[1:] for f in failures)
LOGGER.warning(__("failed to reach any of the inventories "
"with the following issues:") + "\n" + issues)
LOGGER.warning(__('failed to reach any of the inventories '
'with the following issues:') + '\n' + issues)


def fetch_inventory(app: Sphinx, uri: str, inv: str) -> Inventory:
Expand Down Expand Up @@ -218,7 +218,7 @@ def _strip_basic_auth(url: str) -> str:
:rtype: ``str``
"""
frags = list(urlsplit(url))
# swap out "user[:pass]@hostname" for "hostname"
# swap out 'user[:pass]@hostname' for 'hostname'
if '@' in frags[1]:
frags[1] = frags[1].split('@')[1]
return urlunsplit(frags)
Expand Down
13 changes: 6 additions & 7 deletions sphinx/ext/intersphinx/_resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ def _create_element_from_result(domain: Domain, inv_name: str | None,
if node.get('refexplicit'):
# use whatever title was given
newnode.append(contnode)
elif dispname == '-' or \
(domain.name == 'std' and node['reftype'] == 'keyword'):
elif dispname == '-' or (domain.name == 'std' and node['reftype'] == 'keyword'):
# use whatever title was given, but strip prefix
title = contnode.astext()
if inv_name is not None and title.startswith(inv_name + ':'):
Expand Down Expand Up @@ -113,7 +112,7 @@ def _resolve_reference_in_domain(env: BuildEnvironment,

# the inventory contains domain:type as objtype
domain_name = domain.name
obj_types = {f"{domain_name}:{obj_type}": None for obj_type in obj_types}
obj_types = {f'{domain_name}:{obj_type}': None for obj_type in obj_types}

# now that the objtypes list is complete we can remove the disabled ones
if honor_disabled_refs:
Expand Down Expand Up @@ -151,7 +150,7 @@ def _resolve_reference(env: BuildEnvironment, inv_name: str | None, inventory: I
if typ == 'any':
for domain_name, domain in env.domains.items():
if (honor_disabled_refs
and (domain_name + ":*") in env.config.intersphinx_disabled_reftypes):
and (domain_name + ':*') in env.config.intersphinx_disabled_reftypes):
continue
objtypes: Iterable[str] = domain.object_types.keys()
res = _resolve_reference_in_domain(env, inv_name, inventory,
Expand All @@ -166,8 +165,8 @@ def _resolve_reference(env: BuildEnvironment, inv_name: str | None, inventory: I
if not domain_name:
# only objects in domains are in the inventory
return None
if honor_disabled_refs \
and (domain_name + ":*") in env.config.intersphinx_disabled_reftypes:
if (honor_disabled_refs
and (domain_name + ':*') in env.config.intersphinx_disabled_reftypes):
return None
domain = env.get_domain(domain_name)
objtypes = domain.objtypes_for_role(typ) or ()
Expand Down Expand Up @@ -264,7 +263,7 @@ class IntersphinxRole(SphinxRole):
# group 1: just for the optionality of the inventory name
# group 2: the inventory name (optional)
# group 3: the domain:role or role part
_re_inv_ref = re.compile(r"(\+([^:]+))?:(.*)")
_re_inv_ref = re.compile(r'(\+([^:]+))?:(.*)')

def __init__(self, orig_name: str) -> None:
self.orig_name = orig_name
Expand Down

0 comments on commit 88c2782

Please sign in to comment.