Skip to content

Commit d82d370

Browse files
authored
Merge pull request #10078 from danieleades/refactor/unused-loop-control-variables
address some unused loop control variables
2 parents 3b8387f + 9c68cd1 commit d82d370

File tree

37 files changed

+60
-61
lines changed

37 files changed

+60
-61
lines changed

doc/development/tutorials/examples/recipe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def generate(self, docnames=None):
8787
# first letter of the recipe as a key to group thing
8888
#
8989
# name, subtype, docname, anchor, extra, qualifier, description
90-
for name, dispname, typ, docname, anchor, _ in recipes:
90+
for _name, dispname, typ, docname, anchor, _priority in recipes:
9191
content[dispname[0].lower()].append(
9292
(dispname, 0, docname, anchor, docname, '', typ))
9393

sphinx/addnodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class toctree(nodes.General, nodes.Element, translatable):
9292
def preserve_original_messages(self) -> None:
9393
# toctree entries
9494
rawentries = self.setdefault('rawentries', [])
95-
for title, docname in self['entries']:
95+
for title, _docname in self['entries']:
9696
if title:
9797
rawentries.append(title)
9898

sphinx/builders/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ def write_process(docs: List[Tuple[str, nodes.document]]) -> None:
562562
for chunk in status_iterator(chunks, __('writing output... '), "darkgreen",
563563
len(chunks), self.app.verbosity):
564564
arg = []
565-
for i, docname in enumerate(chunk):
565+
for docname in chunk:
566566
doctree = self.env.get_and_resolve_doctree(docname, self)
567567
self.write_doc_serialized(docname, doctree)
568568
arg.append((docname, doctree))

sphinx/builders/_epub_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,14 +377,14 @@ def fix_genindex(self, tree: List[Tuple[str, List[Tuple[str, Any]]]]) -> None:
377377
"""Fix href attributes for genindex pages."""
378378
# XXX: modifies tree inline
379379
# Logic modeled from themes/basic/genindex.html
380-
for key, columns in tree:
381-
for entryname, (links, subitems, key_) in columns:
380+
for _key, columns in tree:
381+
for _entryname, (links, subitems, _key) in columns:
382382
for (i, (ismain, link)) in enumerate(links):
383383
m = self.refuri_re.match(link)
384384
if m:
385385
links[i] = (ismain,
386386
self.fix_fragment(m.group(1), m.group(2)))
387-
for subentryname, subentrylinks in subitems:
387+
for _subentryname, subentrylinks in subitems:
388388
for (i, (ismain, link)) in enumerate(subentrylinks):
389389
m = self.refuri_re.match(link)
390390
if m:

sphinx/builders/gettext.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def write_doc(self, docname: str, doctree: nodes.document) -> None:
157157
if 'index' in self.env.config.gettext_additional_targets:
158158
# Extract translatable messages from index entries.
159159
for node, entries in traverse_translatable_index(doctree):
160-
for typ, msg, tid, main, key_ in entries:
160+
for typ, msg, _tid, _main, _key in entries:
161161
for m in split_index_msg(typ, msg):
162162
if typ == 'pair' and m in pairindextypes.values():
163163
# avoid built-in translated message was incorporated
@@ -227,7 +227,7 @@ def _collect_templates(self) -> Set[str]:
227227
template_files = set()
228228
for template_path in self.config.templates_path:
229229
tmpl_abs_path = path.join(self.app.srcdir, template_path)
230-
for dirpath, dirs, files in walk(tmpl_abs_path):
230+
for dirpath, _dirs, files in walk(tmpl_abs_path):
231231
for fn in files:
232232
if fn.endswith('.html'):
233233
filename = canon_path(path.join(dirpath, fn))
@@ -247,7 +247,7 @@ def _extract_from_template(self) -> None:
247247
try:
248248
with open(template, encoding='utf-8') as f:
249249
context = f.read()
250-
for line, meth, msg in extract_translations(context):
250+
for line, _meth, msg in extract_translations(context):
251251
origin = MsgOrigin(template, line)
252252
self.catalogs['sphinx'].add(msg, origin)
253253
except Exception as exc:

sphinx/builders/html/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ def prepare_writing(self, docnames: Set[str]) -> None:
486486
rellinks: List[Tuple[str, str, str, str]] = []
487487
if self.use_index:
488488
rellinks.append(('genindex', _('General Index'), 'I', _('index')))
489-
for indexname, indexcls, content, collapse in self.domain_indices:
489+
for indexname, indexcls, _content, _collapse in self.domain_indices:
490490
# if it has a short name
491491
if indexcls.shortname:
492492
rellinks.append((indexname, indexcls.localname,

sphinx/builders/linkcheck.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ def __init__(self, env: BuildEnvironment, config: Config,
339339
self.wqueue = PriorityQueue()
340340

341341
def invoke_threads(self) -> None:
342-
for i in range(self.config.linkcheck_workers):
342+
for _i in range(self.config.linkcheck_workers):
343343
thread = HyperlinkAvailabilityCheckWorker(self.env, self.config,
344344
self.rqueue, self.wqueue,
345345
self.rate_limits, self.builder)
@@ -348,7 +348,7 @@ def invoke_threads(self) -> None:
348348

349349
def shutdown_threads(self) -> None:
350350
self.wqueue.join()
351-
for worker in self.workers:
351+
for _worker in self.workers:
352352
self.wqueue.put(CheckRequest(CHECK_IMMEDIATELY, None), False)
353353

354354
def check(self, hyperlinks: Dict[str, Hyperlink]) -> Generator[CheckResult, None, None]:

sphinx/directives/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def run(self) -> List[Node]:
176176

177177
self.names: List[T] = []
178178
signatures = self.get_signatures()
179-
for i, sig in enumerate(signatures):
179+
for sig in signatures:
180180
# add a signature node for each signature in the current unit
181181
# and add a reference target for it
182182
signode = addnodes.desc_signature(sig, '')

sphinx/directives/other.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def run(self) -> List[Node]:
342342
# be placed in the doctree.
343343
n_sects_to_raise = current_depth - nested_depth + 1
344344
parent = cast(nodes.Element, self.state.parent)
345-
for i in range(n_sects_to_raise):
345+
for _i in range(n_sects_to_raise):
346346
if parent.parent:
347347
parent = parent.parent
348348
parent.append(node)

sphinx/domains/c.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3654,8 +3654,7 @@ def run(self) -> List[Node]:
36543654
" When skipping the root declaration,"
36553655
" need 'maxdepth' 0 for infinite or at least 2.",
36563656
location=self.get_location())
3657-
signatures = self.get_signatures()
3658-
for i, sig in enumerate(signatures):
3657+
for sig in self.get_signatures():
36593658
node.append(AliasNode(sig, aliasOptions, self.state.document, env=self.env))
36603659
return [node]
36613660

0 commit comments

Comments
 (0)