Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ type-stubs = [
# align with versions used elsewhere
"types-colorama==0.4.15.20250801",
"types-defusedxml==0.7.0.20250822",
"types-docutils==0.22.3.20251115",
"types-docutils==0.22.3.20260223",
"types-Pillow==10.2.0.20240822",
"types-Pygments==2.19.0.20251121",
"types-requests==2.32.4.20250913",
Expand Down
2 changes: 1 addition & 1 deletion sphinx/builders/gettext.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def _extract_from_template(self) -> None:
logger.info(bold(__('building [%s]: ')), self.name, nonl=True)
logger.info(__('targets for %d template files'), len(files))

extract_translations = self.templates.environment.extract_translations
extract_translations = self.templates.environment.extract_translations # ty: ignore[unresolved-attribute]

for template in status_iterator(
files,
Expand Down
4 changes: 2 additions & 2 deletions sphinx/builders/html/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ def get_doc_context(self, docname: str, body: str, metatags: str) -> dict[str, A
'link': self.get_relative_uri(docname, related[2]),
'title': self.render_partial(titles[related[2]])['title'],
}
rellinks.append((related[2], next['title'], 'N', _('next')))
rellinks.append((related[2], next['title'], 'N', _('next'))) # ty: ignore[unresolved-attribute]
except KeyError:
next = None
if related and related[1]:
Expand All @@ -584,7 +584,7 @@ def get_doc_context(self, docname: str, body: str, metatags: str) -> dict[str, A
'link': self.get_relative_uri(docname, related[1]),
'title': self.render_partial(titles[related[1]])['title'],
}
rellinks.append((related[1], prev['title'], 'P', _('previous')))
rellinks.append((related[1], prev['title'], 'P', _('previous'))) # ty: ignore[unresolved-attribute]
except KeyError:
# the relation is (somehow) not in the TOC tree, handle
# that gracefully
Expand Down
6 changes: 3 additions & 3 deletions sphinx/domains/c/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def _add_enumerator_to_parent(self, ast: ASTDeclaration) -> None:
if s is not None:
# something is already declared with that name
return
decl_clone = symbol.declaration.clone()
decl_clone = symbol.declaration.clone() # ty: ignore[unresolved-attribute]
decl_clone.enumeratorScopedSymbol = symbol
Symbol(
parent=target_symbol,
Expand All @@ -175,7 +175,7 @@ def add_target_and_index(
newest_id = ids[0]
assert newest_id # shouldn't be None

name = ast.symbol.get_full_nested_name().get_display_string().lstrip('.')
name = ast.symbol.get_full_nested_name().get_display_string().lstrip('.') # ty: ignore[unresolved-attribute]
if newest_id not in self.state.document.ids:
# always add the newest id
assert newest_id
Expand Down Expand Up @@ -554,7 +554,7 @@ def _render_symbol(
if not skip_this:
signode = addnodes.desc_signature('', '')
nodes.append(signode)
s.declaration.describe_signature(
s.declaration.describe_signature( # ty: ignore[unresolved-attribute]
signode, 'markName', self.env, render_options
)

Expand Down
8 changes: 4 additions & 4 deletions sphinx/domains/c/_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ def __hash__(self) -> int:

def get_id(self, version: int, objectType: str, symbol: Symbol) -> str:
# the anchor will be our parent
return symbol.parent.declaration.get_id(version, prefixed=False)
return symbol.parent.declaration.get_id(version, prefixed=False) # ty: ignore[unresolved-attribute]

def _stringify(self, transform: StringifyTransform) -> str:
if self.ellipsis:
Expand All @@ -849,7 +849,7 @@ def describe_signature(
if self.ellipsis:
signode += addnodes.desc_sig_punctuation('...', '...')
else:
self.arg.describe_signature(signode, mode, env, symbol=symbol)
self.arg.describe_signature(signode, mode, env, symbol=symbol) # ty: ignore[unresolved-attribute]


class ASTParameters(ASTBase):
Expand Down Expand Up @@ -1670,7 +1670,7 @@ def describe_signature(
name = str(self)
signode += addnodes.desc_sig_name(name, name)
else:
self.arg.describe_signature(signode, mode, env, symbol=symbol)
self.arg.describe_signature(signode, mode, env, symbol=symbol) # ty: ignore[unresolved-attribute]


class ASTMacro(ASTBase):
Expand Down Expand Up @@ -1906,7 +1906,7 @@ def function_params(self) -> list[ASTFunctionParameter] | None:

def get_id(self, version: int, prefixed: bool = True) -> str:
if self.objectType == 'enumerator' and self.enumeratorScopedSymbol:
return self.enumeratorScopedSymbol.declaration.get_id(version, prefixed)
return self.enumeratorScopedSymbol.declaration.get_id(version, prefixed) # ty: ignore[unresolved-attribute]
id_ = self.declaration.get_id(version, self.objectType, self.symbol)
if prefixed:
return _id_prefix[version] + id_
Expand Down
4 changes: 2 additions & 2 deletions sphinx/domains/c/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ def _parse_literal(self) -> ASTLiteral | None:

# character-literal
if self.match(char_literal_re):
prefix = self.last_match.group(1) # may be None when no prefix
data = self.last_match.group(2)
prefix = self.last_match.group(1) # ty: ignore[unresolved-attribute]
data = self.last_match.group(2) # ty: ignore[unresolved-attribute]
try:
return ASTCharLiteral(prefix, data)
except UnicodeDecodeError as e:
Expand Down
10 changes: 5 additions & 5 deletions sphinx/domains/c/_symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,22 +143,22 @@ def _children(self) -> Iterable[Symbol]:
return self._children_by_name.values()

def _add_child(self, child: Symbol) -> None:
name = child.ident.name
name = child.ident.name # ty: ignore[unresolved-attribute]
if name in self._children_by_name:
# Duplicate so don't add - will be reported in _add_symbols()
return
self._children_by_name[name] = child
child_docname: str = child.docname
self._children_by_docname.setdefault(child_docname, {})[name] = child
if child.ident.is_anonymous:
if child.ident.is_anonymous: # ty: ignore[unresolved-attribute]
self._anon_children.add(child)

def _remove_child(self, child: Symbol) -> None:
name = child.ident.name
name = child.ident.name # ty: ignore[unresolved-attribute]
self._children_by_name.pop(name, None)
if children := self._children_by_docname.get(child.docname):
children.pop(name, None)
if child.ident.is_anonymous:
if child.ident.is_anonymous: # ty: ignore[unresolved-attribute]
self._anon_children.discard(child)

def _fill_empty(self, declaration: ASTDeclaration, docname: str, line: int) -> None:
Expand Down Expand Up @@ -551,7 +551,7 @@ def merge_with(

assert other is not None
for other_child in other._children:
other_name = other_child.ident.name
other_name = other_child.ident.name # ty: ignore[unresolved-attribute]
if other_name not in self._children_by_name:
# TODO: hmm, should we prune by docnames?
other_child.parent = self
Expand Down
12 changes: 6 additions & 6 deletions sphinx/domains/cpp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def _add_enumerator_to_parent(self, ast: ASTDeclaration) -> None:
if s is not None:
# something is already declared with that name
return
decl_clone = symbol.declaration.clone()
decl_clone = symbol.declaration.clone() # ty: ignore[unresolved-attribute]
decl_clone.enumeratorScopedSymbol = symbol
Symbol(
parent=target_symbol,
Expand Down Expand Up @@ -247,10 +247,10 @@ def add_target_and_index(
location=self.get_location(),
)

name = ast.symbol.get_full_nested_name().get_display_string().lstrip(':')
name = ast.symbol.get_full_nested_name().get_display_string().lstrip(':') # ty: ignore[unresolved-attribute]
# Add index entry, but not if it's a declaration inside a concept
is_in_concept = False
s = ast.symbol.parent
s = ast.symbol.parent # ty: ignore[unresolved-attribute]
while s is not None:
decl = s.declaration
s = s.parent
Expand Down Expand Up @@ -278,7 +278,7 @@ def add_target_and_index(
# if the name is not unique, the first one will win
names = self.env.domaindata['cpp']['names']
if name not in names:
names[name] = ast.symbol.docname
names[name] = ast.symbol.docname # ty: ignore[unresolved-attribute]
# always add the newest id
assert newest_id
signode['ids'].append(newest_id)
Expand Down Expand Up @@ -424,7 +424,7 @@ def before_content(self) -> None:
self.env.ref_context['cpp:parent_key'] = last_symbol.get_lookup_key()
self.env.current_document.cpp_domain_name = (
*self.env.current_document.cpp_domain_name,
last_symbol.identOrOp._stringify(str),
last_symbol.identOrOp._stringify(str), # ty: ignore[unresolved-attribute]
)

def after_content(self) -> None:
Expand Down Expand Up @@ -672,7 +672,7 @@ def _render_symbol(
if not skip_this:
signode = addnodes.desc_signature('', '')
nodes.append(signode)
s.declaration.describe_signature(
s.declaration.describe_signature( # ty: ignore[unresolved-attribute]
signode, 'markName', self.env, render_options
)

Expand Down
38 changes: 19 additions & 19 deletions sphinx/domains/cpp/_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ def describe_signature(
template_params: list[Any] = []
if mode == 'lastIsName':
assert symbol is not None
if symbol.declaration.templatePrefix is not None:
template_params = symbol.declaration.templatePrefix.templates
if symbol.declaration.templatePrefix is not None: # ty: ignore[unresolved-attribute]
template_params = symbol.declaration.templatePrefix.templates # ty: ignore[unresolved-attribute]
i_template_params = 0
template_params_prefix = ''
prefix = ''
Expand Down Expand Up @@ -2038,7 +2038,7 @@ def get_id(
# this is not part of the normal name mangling in C++
if symbol:
# the anchor will be our parent
return symbol.parent.declaration.get_id(version, prefixed=False)
return symbol.parent.declaration.get_id(version, prefixed=False) # ty: ignore[unresolved-attribute]
# else, do the usual
if self.ellipsis:
return 'z'
Expand Down Expand Up @@ -3394,7 +3394,7 @@ def get_id(
if objectType: # needs the name
if objectType == 'function': # also modifiers
res.extend((
symbol.get_full_nested_name().get_id(version),
symbol.get_full_nested_name().get_id(version), # ty: ignore[unresolved-attribute]
self.decl.get_param_id(version),
self.decl.get_modifiers_id(version),
))
Expand All @@ -3404,7 +3404,7 @@ def get_id(
):
res.append('CE')
elif objectType == 'type': # just the name
res.append(symbol.get_full_nested_name().get_id(version))
res.append(symbol.get_full_nested_name().get_id(version)) # ty: ignore[unresolved-attribute]
else:
raise AssertionError(objectType)
else: # only type encoding
Expand All @@ -3421,10 +3421,10 @@ def get_id(
if objectType: # needs the name
if objectType == 'function': # also modifiers
modifiers = self.decl.get_modifiers_id(version)
res.append(symbol.get_full_nested_name().get_id(version, modifiers))
res.append(symbol.get_full_nested_name().get_id(version, modifiers)) # ty: ignore[unresolved-attribute]
if version >= 4:
# with templates we need to mangle the return type in as well
templ = symbol.declaration.templatePrefix
templ = symbol.declaration.templatePrefix # ty: ignore[unresolved-attribute]
if templ is not None:
type_id = self.decl.get_ptr_suffix_id(version)
if self.trailingReturn:
Expand All @@ -3435,7 +3435,7 @@ def get_id(
res.append(return_type_id)
res.append(self.decl.get_param_id(version))
elif objectType == 'type': # just the name
res.append(symbol.get_full_nested_name().get_id(version))
res.append(symbol.get_full_nested_name().get_id(version)) # ty: ignore[unresolved-attribute]
else:
raise AssertionError(objectType)
else: # only type encoding
Expand Down Expand Up @@ -3504,7 +3504,7 @@ def get_id(
assert version >= 2
if symbol:
# the anchor will be our parent
return symbol.parent.declaration.get_id(version, prefixed=False)
return symbol.parent.declaration.get_id(version, prefixed=False) # ty: ignore[unresolved-attribute]
else:
return self.type.get_id(version)

Expand Down Expand Up @@ -3554,11 +3554,11 @@ def get_id(
return self.type.get_id(version, objectType)
if version == 1:
return (
symbol.get_full_nested_name().get_id(version)
symbol.get_full_nested_name().get_id(version) # ty: ignore[unresolved-attribute]
+ '__'
+ self.type.get_id(version)
)
return symbol.get_full_nested_name().get_id(version)
return symbol.get_full_nested_name().get_id(version) # ty: ignore[unresolved-attribute]

def _stringify(self, transform: StringifyTransform) -> str:
res = [transform(self.type)]
Expand Down Expand Up @@ -3593,7 +3593,7 @@ def get_id(
) -> str:
if version == 1:
raise NoOldIdError
return symbol.get_full_nested_name().get_id(version)
return symbol.get_full_nested_name().get_id(version) # ty: ignore[unresolved-attribute]

def _stringify(self, transform: StringifyTransform) -> str:
res = [transform(self.name)]
Expand Down Expand Up @@ -3645,7 +3645,7 @@ def get_id(
) -> str:
if version == 1:
raise NoOldIdError
return symbol.get_full_nested_name().get_id(version)
return symbol.get_full_nested_name().get_id(version) # ty: ignore[unresolved-attribute]

def _stringify(self, transform: StringifyTransform) -> str:
res = transform(self.nestedName)
Expand Down Expand Up @@ -4051,7 +4051,7 @@ def get_id(
assert version >= 2
if symbol:
# the anchor will be our parent
return symbol.parent.declaration.get_id(version, prefixed=False)
return symbol.parent.declaration.get_id(version, prefixed=False) # ty: ignore[unresolved-attribute]
else:
return self.data.get_id(version)

Expand Down Expand Up @@ -4100,7 +4100,7 @@ def get_id(
# this is not part of the normal name mangling in C++
if symbol:
# the anchor will be our parent
return symbol.parent.declaration.get_id(version, prefixed=None)
return symbol.parent.declaration.get_id(version, prefixed=None) # ty: ignore[unresolved-attribute]
else:
return self.nestedParams.get_id(version) + self.data.get_id(version)

Expand Down Expand Up @@ -4161,7 +4161,7 @@ def get_id(
# this is not part of the normal name mangling in C++
if symbol:
# the anchor will be our parent
return symbol.parent.declaration.get_id(version, prefixed=None)
return symbol.parent.declaration.get_id(version, prefixed=None) # ty: ignore[unresolved-attribute]
else:
res = '_'
if self.parameterPack:
Expand Down Expand Up @@ -4312,7 +4312,7 @@ def get_id(
# this is not part of the normal name mangling in C++
if symbol:
# the anchor will be our parent
return symbol.parent.declaration.get_id(version, prefixed=None)
return symbol.parent.declaration.get_id(version, prefixed=None) # ty: ignore[unresolved-attribute]
else:
if self.parameterPack:
return 'Dp'
Expand Down Expand Up @@ -4584,11 +4584,11 @@ def get_id(self, version: int, prefixed: bool = True) -> str:
if self.templatePrefix or self.trailingRequiresClause:
raise NoOldIdError
if self.objectType == 'enumerator' and self.enumeratorScopedSymbol:
return self.enumeratorScopedSymbol.declaration.get_id(version)
return self.enumeratorScopedSymbol.declaration.get_id(version) # ty: ignore[unresolved-attribute]
return self.declaration.get_id(version, self.objectType, self.symbol)
# version >= 2
if self.objectType == 'enumerator' and self.enumeratorScopedSymbol:
return self.enumeratorScopedSymbol.declaration.get_id(version, prefixed)
return self.enumeratorScopedSymbol.declaration.get_id(version, prefixed) # ty: ignore[unresolved-attribute]
if prefixed:
res = [_id_prefix[version]]
else:
Expand Down
6 changes: 3 additions & 3 deletions sphinx/domains/cpp/_symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def get_all_symbols(self) -> Iterator[Any]:
def children_recurse_anon(self) -> Iterator[Symbol]:
for c in self._children:
yield c
if not c.identOrOp.is_anon():
if not c.identOrOp.is_anon(): # ty: ignore[unresolved-attribute]
continue

yield from c.children_recurse_anon
Expand Down Expand Up @@ -959,8 +959,8 @@ def merge_with(
else:
our_object_type = our_child.declaration.objectType
other_object_type = other_child.declaration.objectType
our_child_parent_decl = our_child.parent.declaration
other_child_parent_decl = other_child.parent.declaration
our_child_parent_decl = our_child.parent.declaration # ty: ignore[unresolved-attribute]
other_child_parent_decl = other_child.parent.declaration # ty: ignore[unresolved-attribute]
if (
other_object_type == our_object_type
and other_object_type in {'templateParam', 'functionParam'}
Expand Down
2 changes: 1 addition & 1 deletion sphinx/ext/apidoc/_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def is_initpy(filename: str | Path) -> bool:
"""Check *filename* is __init__ file or not."""
basename = Path(filename).name
return any(
basename == '__init__' + suffix
basename == '__init__' + suffix # ty: ignore[unsupported-operator]
for suffix in sorted(PY_SUFFIXES, key=len, reverse=True)
)

Expand Down
4 changes: 2 additions & 2 deletions sphinx/ext/autodoc/_dynamic/_member_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ def _get_members_to_document(
if (
props.obj_type == 'module'
and not ignore_module_all
and props.all is not None
and props.all is not None # ty: ignore[unresolved-attribute]
):
wanted_members = frozenset(props.all)
wanted_members = frozenset(props.all) # ty: ignore[unresolved-attribute]
else:
wanted_members = ALL
else:
Expand Down
Loading
Loading