convert some range(len()) calls for pylint

This commit is contained in:
Damien Elmes 2021-10-02 23:37:12 +10:00
parent 553ce808e5
commit fe576a865d
3 changed files with 7 additions and 9 deletions

View file

@ -143,12 +143,12 @@ class NoteImporter(Importer):
dupeCount = 0 dupeCount = 0
dupes: List[str] = [] dupes: List[str] = []
for n in notes: for n in notes:
for c in range(len(n.fields)): for c, field in enumerate(n.fields):
if not self.allowHTML: if not self.allowHTML:
n.fields[c] = html.escape(n.fields[c], quote=False) n.fields[c] = html.escape(field, quote=False)
n.fields[c] = n.fields[c].strip() n.fields[c] = field.strip()
if not self.allowHTML: if not self.allowHTML:
n.fields[c] = n.fields[c].replace("\n", "<br>") n.fields[c] = field.replace("\n", "<br>")
fld0 = unicodedata.normalize("NFC", n.fields[fld0idx]) fld0 = unicodedata.normalize("NFC", n.fields[fld0idx])
# first field must exist # first field must exist
if not fld0: if not fld0:

View file

@ -197,8 +197,7 @@ limit %d"""
% (self._deckLimit(), self.reportLimit), % (self._deckLimit(), self.reportLimit),
self.dayCutoff, self.dayCutoff,
) )
for i in range(len(self._lrnQueue)): self._lrnQueue = [tuple(e) for e in self._lrnQueue]
self._lrnQueue[i] = (self._lrnQueue[i][0], self._lrnQueue[i][1])
# as it arrives sorted by did first, we need to sort it # as it arrives sorted by did first, we need to sort it
self._lrnQueue.sort() self._lrnQueue.sort()
return self._lrnQueue return self._lrnQueue

View file

@ -8,7 +8,7 @@ from __future__ import annotations
import random import random
import time import time
from heapq import * from heapq import *
from typing import Any, Callable, Dict, List, Optional, Tuple, Union from typing import Any, Callable, Dict, List, Optional, Tuple, Union, cast
import anki # pylint: disable=unused-import import anki # pylint: disable=unused-import
from anki import hooks, scheduler_pb2 from anki import hooks, scheduler_pb2
@ -329,8 +329,7 @@ limit %d"""
% (self._deckLimit(), self.reportLimit), % (self._deckLimit(), self.reportLimit),
cutoff, cutoff,
) )
for i in range(len(self._lrnQueue)): self._lrnQueue = [cast(Tuple[int, CardId], tuple(e)) for e in self._lrnQueue]
self._lrnQueue[i] = (self._lrnQueue[i][0], self._lrnQueue[i][1])
# as it arrives sorted by did first, we need to sort it # as it arrives sorted by did first, we need to sort it
self._lrnQueue.sort() self._lrnQueue.sort()
return self._lrnQueue return self._lrnQueue