Skip to content

Commit

Permalink
ignore more pylint errors per-case
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Mar 14, 2024
1 parent 4e1f1c6 commit 0714c44
Show file tree
Hide file tree
Showing 28 changed files with 44 additions and 46 deletions.
2 changes: 1 addition & 1 deletion pyglossary/glossary.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def sortWords(
self._sort = True
self._iter = self._loadedEntryGen()

def convert(
def convert( # noqa: PLR0913
self,
inputFilename: str,
inputFormat: str = "",
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/option.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "",
Expand Down
4 changes: 2 additions & 2 deletions pyglossary/plugins/appledict_bin/key_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
show article with title "fine" and point to element id = 'm_en_gbus0362750.070'
"""


# TODO: switch to dataclass
class KeyData:

"""
Expand Down Expand Up @@ -77,7 +77,7 @@ class KeyData:
"priority",
]

def __init__(
def __init__( # noqa: PLR0913
self,
priority: int,
parentalControl: int,
Expand Down
3 changes: 2 additions & 1 deletion pyglossary/plugins/babylon_bgl/bgl_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
__all__ = ["BabylonLanguage", "languageByCode"]


# TODO: switch to dataclass
class BabylonLanguage:

"""
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/plugins/cc_kedict.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "",
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/plugins/freedict.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class Reader:
gramClass = "grammar"

@staticmethod
def makeList(
def makeList( # noqa: PLR0913
hf: "T_htmlfile",
input_objects: "list[Any]",
processor: "Callable",
Expand Down
8 changes: 4 additions & 4 deletions pyglossary/plugins/quickdic6.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]],
Expand Down Expand Up @@ -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 {}
Expand Down Expand Up @@ -881,7 +882,6 @@ def write(self) -> "typing.Generator[None, EntryType, None]":
long_name,
iso,
normalizer_rules,
False,
synonyms=synonyms,
)

Expand Down
2 changes: 1 addition & 1 deletion pyglossary/plugins/wiktextract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions pyglossary/slob.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def __contains__(self, key: str) -> bool:


class Blob:
def __init__(
def __init__( # noqa: PLR0913
self,
content_id: int,
key: str,
Expand Down Expand Up @@ -1018,7 +1018,7 @@ def key(self) -> str:


class Writer:
def __init__(
def __init__( # noqa: PLR0913
self,
filename: str,
workdir: "str | None" = None,
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/sq_entry_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@


class SqEntryList:
def __init__(
def __init__( # noqa: PLR0913
self,
entryToRaw: "Callable[[EntryType], RawEntryType]",
entryFromRaw: "Callable[[RawEntryType], EntryType]",
Expand Down
5 changes: 3 additions & 2 deletions pyglossary/text_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 = "",
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/ui/gtk3_utils/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


class AboutWidget(gtk.Box):
def __init__(
def __init__( # noqa: PLR0913
self,
logo: str = "",
header: str = "",
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/ui/gtk3_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def dialog_add_button(
return b


def showMsg(
def showMsg( # noqa: PLR0913
msg,
iconName="",
parent=None,
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/ui/gtk4_utils/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "",
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/ui/gtk4_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def dialog_add_button(
return label


def showMsg(
def showMsg( # noqa: PLR0913
msg,
iconName="",
parent=None,
Expand Down
4 changes: 2 additions & 2 deletions pyglossary/ui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -182,7 +182,7 @@ def registerConfigOption(
)


def base_ui_run(
def base_ui_run( # noqa: PLR0913
inputFilename: str = "",
outputFilename: str = "",
inputFormat: str = "",
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/ui/tools/diff_glossary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/ui/ui_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def reverseLoop(
input()
self._toPause = False

def run(
def run( # noqa: PLR0913
self,
inputFilename: str = "",
outputFilename: str = "",
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/ui/ui_cmd_interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "",
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/ui/ui_gtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,7 @@ def __init__(
########
self.status("Select input file")

def run(
def run( # noqa: PLR0913
self,
inputFilename: str = "",
outputFilename: str = "",
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/ui/ui_gtk4.py
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,7 @@ def __init__(
########
self.status("Select input file")

def run(
def run( # noqa: PLR0913
self,
inputFilename: str = "",
outputFilename: str = "",
Expand Down
6 changes: 3 additions & 3 deletions pyglossary/ui/ui_tk.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class ProgressBar(tix.Frame):
Edited by Saeed Rasooli.
"""

def __init__(
def __init__( # noqa: PLR0913
self,
rootWin=None,
orientation="horizontal",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 = "",
Expand Down
6 changes: 3 additions & 3 deletions pyglossary/xdxf/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
10 changes: 3 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
4 changes: 2 additions & 2 deletions tests/g_stardict_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


class TestGlossaryStarDictBase(TestGlossaryErrorsBase):
def convert_txt_stardict(
def convert_txt_stardict( # noqa: PLR0913
self,
fname,
fname2="",
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/glossary_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/glossary_v2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0714c44

Please sign in to comment.