Skip to content

Commit

Permalink
fix some mypy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Jun 30, 2024
1 parent 578c854 commit 6ca9902
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 11 deletions.
6 changes: 3 additions & 3 deletions pyglossary/glossary_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def __init__(
self._sqlite = False
self._rawEntryCompress = False
self._cleanupPathList: "set[str]" = set()
self._readOptions = None
self._readOptions: dict[str, Any] | None = None

self.clear()

Expand Down Expand Up @@ -572,7 +572,7 @@ def newEntry(
byteProgress=byteProgress,
)

def newDataEntry(self, fname: str, data: bytes) -> "DataEntry":
def newDataEntry(self, fname: str, data: bytes) -> "EntryType":
import uuid

if self._readers:
Expand Down Expand Up @@ -839,7 +839,7 @@ def _writeEntries(

if self._config.get("save_info_json", False):
from pyglossary.info_writer import InfoWriter
infoWriter = InfoWriter(self)
infoWriter = InfoWriter(cast(GlossaryType, self))
filenameNoExt, _, _, _ = splitFilenameExt(filename)
infoWriter.open(f"{filenameNoExt}.info")
genList.append(infoWriter.write())
Expand Down
4 changes: 2 additions & 2 deletions pyglossary/plugins/abc_medical_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from collections.abc import Iterator

from pyglossary.glossary_types import EntryType, GlossaryType

from pyglossary.option import Option

__all__ = [
"Reader",
Expand Down Expand Up @@ -39,7 +39,7 @@
_url,
"ABC Medical Notes 2021 - Google Play",
)
optionsProp = {}
optionsProp: "dict[str, Option]" = {}


class Reader:
Expand Down
3 changes: 2 additions & 1 deletion pyglossary/plugins/almaany.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from collections.abc import Iterator

from pyglossary.glossary_types import EntryType, GlossaryType
from pyglossary.option import Option

__all__ = [
"Reader",
Expand Down Expand Up @@ -37,7 +38,7 @@
"https://play.google.com/store/apps/details?id=com.almaany.arar",
"Almaany.com Arabic Dictionary - Google Play",
)
optionsProp = {}
optionsProp: "dict[str, Option]" = {}


class Reader:
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/plugins/crawler_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def _readDir(
self,
dpath: str,
exclude: "set[str] | None",
) -> "Generator[None, EntryType, None]":
) -> "Generator[EntryType, None, None]":
children = listdir(dpath)
if exclude:
children = [name for name in children if name not in exclude]
Expand Down
3 changes: 2 additions & 1 deletion pyglossary/plugins/dict_cc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from pyglossary.glossary_types import EntryType, GlossaryType
from pyglossary.lxml_types import Element, T_htmlfile
from pyglossary.option import Option


from pyglossary.core import log
Expand Down Expand Up @@ -42,7 +43,7 @@
"https://play.google.com/store/apps/details?id=cc.dict.dictcc",
"dict.cc dictionary - Google Play",
)
optionsProp = {}
optionsProp: "dict[str, Option]" = {}


class Reader:
Expand Down
3 changes: 2 additions & 1 deletion pyglossary/plugins/dict_cc_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import sqlite3

from pyglossary.glossary_types import EntryType, GlossaryType
from pyglossary.option import Option

from pyglossary.core import log

Expand Down Expand Up @@ -39,7 +40,7 @@
"https://play.google.com/store/apps/details?id=cc.dict.dictcc",
"dict.cc dictionary - Google Play",
)
optionsProp = {}
optionsProp: "dict[str, Option]" = {}


class Reader:
Expand Down
3 changes: 2 additions & 1 deletion pyglossary/plugins/digitalnk.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import sqlite3

from pyglossary.glossary_types import EntryType, GlossaryType
from pyglossary.option import Option

__all__ = [
"Reader",
Expand Down Expand Up @@ -37,7 +38,7 @@
"https://github.com/digitalprk/dicrs",
"@digitalprk/dicrs",
)
optionsProp = {}
optionsProp: "dict[str, Option]" = {}


class Reader:
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/plugins/stardict_textual.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def renderDefiList(
if len(defisWithFormat) == 1:
return defisWithFormat[0]

defiFormatSet = set()
defiFormatSet: set[str] = set()
defiFormatSet.update(_type for _, _type in defisWithFormat)

if len(defiFormatSet) == 1:
Expand Down
1 change: 1 addition & 0 deletions pyglossary/plugins/tabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def open(self, filename: str) -> "Iterator[tuple[int, int]] | None":
if isdir(resDir):
self._resDir = resDir
self._resFileNames = os.listdir(self._resDir)
return None # noqa: B901 because of mypy

def __iter__(self) -> "Iterator[EntryType | None]":
yield from TextGlossaryReader.__iter__(self)
Expand Down

0 comments on commit 6ca9902

Please sign in to comment.