diff --git a/pyglossary/glossary.py b/pyglossary/glossary.py index 674b309b1..4f9962bbd 100644 --- a/pyglossary/glossary.py +++ b/pyglossary/glossary.py @@ -139,7 +139,7 @@ def sortWords( self._sort = True self._iter = self._loadedEntryGen() - def convert( + def convert( # noqa: PLR0913 self, inputFilename: str, inputFormat: str = "", diff --git a/pyglossary/option.py b/pyglossary/option.py index 01ea81c79..c569ab2ef 100644 --- a/pyglossary/option.py +++ b/pyglossary/option.py @@ -42,7 +42,7 @@ def register(cls: "type[Option]", optClass: "type") -> "type": cls.classes[optClass.__name__] = optClass return optClass - def __init__( + def __init__( # noqa: PLR0913 self, typ: str, customValue: bool = False, diff --git a/pyglossary/plugin_manager.py b/pyglossary/plugin_manager.py index ba9978027..11b08cb16 100644 --- a/pyglossary/plugin_manager.py +++ b/pyglossary/plugin_manager.py @@ -259,7 +259,7 @@ def _outputPluginByFormat( # where the str is error # and remove `quiet` argument, and local `error` function @classmethod - def detectOutputFormat( + def detectOutputFormat( # noqa: PLR0913 cls: "type[PluginManager]", filename: str = "", format: str = "", diff --git a/pyglossary/plugins/appledict_bin/key_data.py b/pyglossary/plugins/appledict_bin/key_data.py index 30f0e23ac..7a16e737a 100644 --- a/pyglossary/plugins/appledict_bin/key_data.py +++ b/pyglossary/plugins/appledict_bin/key_data.py @@ -41,7 +41,7 @@ show article with title "fine" and point to element id = 'm_en_gbus0362750.070' """ - +# TODO: switch to dataclass class KeyData: """ @@ -77,7 +77,7 @@ class KeyData: "priority", ] - def __init__( + def __init__( # noqa: PLR0913 self, priority: int, parentalControl: int, diff --git a/pyglossary/plugins/babylon_bgl/bgl_language.py b/pyglossary/plugins/babylon_bgl/bgl_language.py index e90850688..6e620a63c 100644 --- a/pyglossary/plugins/babylon_bgl/bgl_language.py +++ b/pyglossary/plugins/babylon_bgl/bgl_language.py @@ -116,6 +116,7 @@ __all__ = ["BabylonLanguage", "languageByCode"] +# TODO: switch to dataclass class BabylonLanguage: """ @@ -130,7 +131,7 @@ class BabylonLanguage: code - value of the type 3, code in .bgl file """ - def __init__( + def __init__( # noqa: PLR0913 self, name: str, charset: str, diff --git a/pyglossary/plugins/cc_kedict.py b/pyglossary/plugins/cc_kedict.py index af18f9dfc..0b10b1e58 100644 --- a/pyglossary/plugins/cc_kedict.py +++ b/pyglossary/plugins/cc_kedict.py @@ -56,7 +56,7 @@ class YamlReader(TextGlossaryReader): # 0.5ex ~= 0.3em, but "ex" is recommended ) - def __init__( + def __init__( # noqa: PLR0913 self, glos: "GlossaryType", spellKey: str = "", diff --git a/pyglossary/plugins/freedict.py b/pyglossary/plugins/freedict.py index 5d7dff0d3..87fa32ff7 100644 --- a/pyglossary/plugins/freedict.py +++ b/pyglossary/plugins/freedict.py @@ -156,7 +156,7 @@ class Reader: gramClass = "grammar" @staticmethod - def makeList( + def makeList( # noqa: PLR0913 hf: "T_htmlfile", input_objects: "list[Any]", processor: "Callable", diff --git a/pyglossary/plugins/quickdic6.py b/pyglossary/plugins/quickdic6.py index 47429ccd6..4520be071 100644 --- a/pyglossary/plugins/quickdic6.py +++ b/pyglossary/plugins/quickdic6.py @@ -514,8 +514,9 @@ def _without_dash(a: str) -> str: return a.replace("-", "").replace("þ", "th").replace("Þ", "Th") +# TODO: switch to dataclass class QuickDic: - def __init__( + def __init__( # noqa: PLR0913 self, name: str, sources: list[tuple[str, int]], @@ -568,15 +569,15 @@ def from_fp(cls: "type[QuickDic]", fp: IO[bytes]) -> "QuickDic": created=created, ) - def add_index( + def add_index( # noqa: PLR0913 self, short_name: str, long_name: str, iso: str, normalizer_rules: str, - swap_flag: bool, synonyms: dict | None = None, ) -> None: + swap_flag = False comparator = Comparator(iso, normalizer_rules, self.version) synonyms = synonyms or {} @@ -881,7 +882,6 @@ def write(self) -> "typing.Generator[None, EntryType, None]": long_name, iso, normalizer_rules, - False, synonyms=synonyms, ) diff --git a/pyglossary/plugins/wiktextract.py b/pyglossary/plugins/wiktextract.py index 542f2831a..132c3aeeb 100644 --- a/pyglossary/plugins/wiktextract.py +++ b/pyglossary/plugins/wiktextract.py @@ -624,7 +624,7 @@ def writeSense( hf.write(ET.Element("br")) @staticmethod - def makeList( + def makeList( # noqa: PLR0913 hf: "T_htmlfile", input_objects: "list[Any]", processor: "Callable", diff --git a/pyglossary/slob.py b/pyglossary/slob.py index aa84f70dd..ce2e766f0 100644 --- a/pyglossary/slob.py +++ b/pyglossary/slob.py @@ -380,7 +380,7 @@ def __contains__(self, key: str) -> bool: class Blob: - def __init__( + def __init__( # noqa: PLR0913 self, content_id: int, key: str, @@ -1018,7 +1018,7 @@ def key(self) -> str: class Writer: - def __init__( + def __init__( # noqa: PLR0913 self, filename: str, workdir: "str | None" = None, diff --git a/pyglossary/sq_entry_list.py b/pyglossary/sq_entry_list.py index 897f1aeec..34335a07e 100644 --- a/pyglossary/sq_entry_list.py +++ b/pyglossary/sq_entry_list.py @@ -51,7 +51,7 @@ class SqEntryList: - def __init__( + def __init__( # noqa: PLR0913 self, entryToRaw: "Callable[[EntryType], RawEntryType]", entryFromRaw: "Callable[[RawEntryType], EntryType]", diff --git a/pyglossary/text_writer.py b/pyglossary/text_writer.py index 49dfd04e8..41704cde4 100644 --- a/pyglossary/text_writer.py +++ b/pyglossary/text_writer.py @@ -57,7 +57,8 @@ def __init__( self._outInfoKeysAliasDict = outInfoKeysAliasDict # TODO: replace outInfoKeysAliasDict arg with a func? - def setAttrs( + # TODO: use @property setters + def setAttrs( # noqa: PLR0913 self, encoding: "str | None" = None, newline: "str | None" = None, @@ -210,7 +211,7 @@ def finish(self) -> None: os.rmdir(self._resDir) -def writeTxt( +def writeTxt( # noqa: PLR0913 glos: "GlossaryType", entryFmt: str = "", # contain {word} and {defi} filename: str = "", diff --git a/pyglossary/ui/gtk3_utils/about.py b/pyglossary/ui/gtk3_utils/about.py index 1ce1734fe..d33f9db7d 100644 --- a/pyglossary/ui/gtk3_utils/about.py +++ b/pyglossary/ui/gtk3_utils/about.py @@ -28,7 +28,7 @@ class AboutWidget(gtk.Box): - def __init__( + def __init__( # noqa: PLR0913 self, logo: str = "", header: str = "", diff --git a/pyglossary/ui/gtk3_utils/utils.py b/pyglossary/ui/gtk3_utils/utils.py index 1dbdf3a4c..6fa1b3833 100644 --- a/pyglossary/ui/gtk3_utils/utils.py +++ b/pyglossary/ui/gtk3_utils/utils.py @@ -121,7 +121,7 @@ def dialog_add_button( return b -def showMsg( +def showMsg( # noqa: PLR0913 msg, iconName="", parent=None, diff --git a/pyglossary/ui/gtk4_utils/about.py b/pyglossary/ui/gtk4_utils/about.py index 3787052f6..d169373b7 100644 --- a/pyglossary/ui/gtk4_utils/about.py +++ b/pyglossary/ui/gtk4_utils/about.py @@ -55,7 +55,7 @@ def __init__(self, title: str, icon: str) -> None: class AboutWidget(gtk.Box): - def __init__( + def __init__( # noqa: PLR0913 self, logo: str = "", header: str = "", diff --git a/pyglossary/ui/gtk4_utils/utils.py b/pyglossary/ui/gtk4_utils/utils.py index 219e42ad6..176330047 100644 --- a/pyglossary/ui/gtk4_utils/utils.py +++ b/pyglossary/ui/gtk4_utils/utils.py @@ -155,7 +155,7 @@ def dialog_add_button( return label -def showMsg( +def showMsg( # noqa: PLR0913 msg, iconName="", parent=None, diff --git a/pyglossary/ui/main.py b/pyglossary/ui/main.py index 4fd98394e..62522482a 100644 --- a/pyglossary/ui/main.py +++ b/pyglossary/ui/main.py @@ -102,7 +102,7 @@ def __init__( self.same_dest = same_dest self.const_value = const_value - def __call__( + def __call__( # noqa: PLR0913 self, parser: "argparse.ArgumentParser | None" = None, namespace: "argparse.Namespace | None" = None, @@ -182,7 +182,7 @@ def registerConfigOption( ) -def base_ui_run( +def base_ui_run( # noqa: PLR0913 inputFilename: str = "", outputFilename: str = "", inputFormat: str = "", diff --git a/pyglossary/ui/tools/diff_glossary.py b/pyglossary/ui/tools/diff_glossary.py index 8ee95d419..cfdab178f 100755 --- a/pyglossary/ui/tools/diff_glossary.py +++ b/pyglossary/ui/tools/diff_glossary.py @@ -56,7 +56,7 @@ def formatInfoValueDiff(diff: "Iterator[str]") -> str: return a + "\n" + b -def diffGlossary( +def diffGlossary( # noqa: PLR0913 filename1: str, filename2: str, format1: "str | None" = None, diff --git a/pyglossary/ui/ui_cmd.py b/pyglossary/ui/ui_cmd.py index ee04d6e21..7f2913e91 100644 --- a/pyglossary/ui/ui_cmd.py +++ b/pyglossary/ui/ui_cmd.py @@ -261,7 +261,7 @@ def reverseLoop( input() self._toPause = False - def run( + def run( # noqa: PLR0913 self, inputFilename: str = "", outputFilename: str = "", diff --git a/pyglossary/ui/ui_cmd_interactive.py b/pyglossary/ui/ui_cmd_interactive.py index 86d25a06b..722996a14 100644 --- a/pyglossary/ui/ui_cmd_interactive.py +++ b/pyglossary/ui/ui_cmd_interactive.py @@ -1096,7 +1096,7 @@ def main(self, again=False): return succeed print("Press Control + C to exit") - def run( + def run( # noqa: PLR0913 self, inputFilename: str = "", outputFilename: str = "", diff --git a/pyglossary/ui/ui_gtk.py b/pyglossary/ui/ui_gtk.py index a6c85dbf2..857bfd6d4 100644 --- a/pyglossary/ui/ui_gtk.py +++ b/pyglossary/ui/ui_gtk.py @@ -1361,7 +1361,7 @@ def __init__( ######## self.status("Select input file") - def run( + def run( # noqa: PLR0913 self, inputFilename: str = "", outputFilename: str = "", diff --git a/pyglossary/ui/ui_gtk4.py b/pyglossary/ui/ui_gtk4.py index def15a974..21d76d470 100644 --- a/pyglossary/ui/ui_gtk4.py +++ b/pyglossary/ui/ui_gtk4.py @@ -1451,7 +1451,7 @@ def __init__( ######## self.status("Select input file") - def run( + def run( # noqa: PLR0913 self, inputFilename: str = "", outputFilename: str = "", diff --git a/pyglossary/ui/ui_tk.py b/pyglossary/ui/ui_tk.py index 863dc01b6..4c786119a 100644 --- a/pyglossary/ui/ui_tk.py +++ b/pyglossary/ui/ui_tk.py @@ -209,7 +209,7 @@ class ProgressBar(tix.Frame): Edited by Saeed Rasooli. """ - def __init__( + def __init__( # noqa: PLR0913 self, rootWin=None, orientation="horizontal", @@ -314,7 +314,7 @@ def update(self, event=None, labelText=""): # noqa: ARG002 class FormatDialog(tix.Toplevel): - def __init__( + def __init__( # noqa: PLR0913 self, descList: "list[str]", title: str, @@ -1505,7 +1505,7 @@ def convert(self): # self.status("Convert failed") return bool(finalOutputFile) - def run( + def run( # noqa: PLR0913 self, inputFilename: str = "", outputFilename: str = "", diff --git a/pyglossary/xdxf/transform.py b/pyglossary/xdxf/transform.py index d2123fa2d..1eb46d581 100644 --- a/pyglossary/xdxf/transform.py +++ b/pyglossary/xdxf/transform.py @@ -96,7 +96,7 @@ def hasPrevText(prev: "None | str | Element") -> bool: # print(prev) return False - def writeString( + def writeString( # noqa: PLR0913 self, hf: "T_htmlfile", child: str, @@ -330,7 +330,7 @@ def _write_etm(self, hf: "T_htmlfile", child: "Element") -> None: # noqa: PLR63 # TODO: formatting? hf.write(f"{child.text}") - def writeChildElem( + def writeChildElem( # noqa: PLR0913 self, hf: "T_htmlfile", child: "Element", @@ -355,7 +355,7 @@ def writeChildElem( log.warning(f"unknown tag {child.tag}") self.writeChildrenOf(hf, child) - def writeChild( + def writeChild( # noqa: PLR0913 self, hf: "T_htmlfile", child: "str | Element", diff --git a/pyproject.toml b/pyproject.toml index c1f45ec49..af0dceb86 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,14 +71,10 @@ lint.ignore = [ "DTZ005", # The use of `datetime.datetime.now()` without `tz` argument is not allowed "PGH003", # Use specific rule codes when ignoring type issues - "PLR0904", # Too many public methods (? > 20) - "PLR0912", # Too many branches - "PLR0913", # Too many arguments in function definition - "PLR0914", # Too many local variables - "PLR0915", # Too many statements - "PLR0917", # Too many positional arguments - "PLR2004", # Magic value used in comparison, consider replacing `...` with a constant variable + "PLR0912", # Too many branches, 38 cases + "PLR0915", # Too many statements, 28 cases + "PLR2004", # Magic value used in comparison, consider replacing `...` with a constant variable "PLC0415", # `import` should be at the top-level of a file "PLW0603", # Using the global statement to update `mockLog` is discouraged "PT027", # Use `pytest.raises` instead of unittest-style `assertRaises`, why? diff --git a/tests/g_stardict_test.py b/tests/g_stardict_test.py index 2e64ecd17..f88aeb976 100644 --- a/tests/g_stardict_test.py +++ b/tests/g_stardict_test.py @@ -13,7 +13,7 @@ class TestGlossaryStarDictBase(TestGlossaryErrorsBase): - def convert_txt_stardict( + def convert_txt_stardict( # noqa: PLR0913 self, fname, fname2="", @@ -67,7 +67,7 @@ def convert_txt_stardict( self.downloadFile(f"{fname2}.sd/{fname2}.{ext}"), ) - def convert_txt_stardict_zip( + def convert_txt_stardict_zip( # noqa: PLR0913 self, fname, sha1sumDict, diff --git a/tests/glossary_test.py b/tests/glossary_test.py index 328e2ea80..aa576a9d2 100644 --- a/tests/glossary_test.py +++ b/tests/glossary_test.py @@ -223,7 +223,7 @@ def checkZipFileSha1sum( actualSha1 = hashlib.sha1(data).hexdigest() self.assertEqual(actualSha1, expectedSha1, msg=f"file: {zfpath}") - def convert( + def convert( # noqa: PLR0913 self, fname, # input file with extension fname2, # output file with extension diff --git a/tests/glossary_v2_test.py b/tests/glossary_v2_test.py index 83a9bfaee..04e39ef8f 100644 --- a/tests/glossary_v2_test.py +++ b/tests/glossary_v2_test.py @@ -224,7 +224,7 @@ def checkZipFileSha1sum( actualSha1 = hashlib.sha1(data).hexdigest() self.assertEqual(actualSha1, expectedSha1, msg=f"file: {zfpath}") - def convert( + def convert( # noqa: PLR0913 self, fname, # input file with extension fname2, # output file with extension