Skip to content

Commit

Permalink
update pyproject.toml, and ignore PLR0904
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Mar 16, 2024
1 parent 2833073 commit b674a0f
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 137 deletions.
2 changes: 1 addition & 1 deletion pyglossary/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@


# aka Resource
class DataEntry(BaseEntry):
class DataEntry(BaseEntry): # noqa: PLR0904
__slots__ = [
"_byteProgress",
"_data",
Expand Down
4 changes: 2 additions & 2 deletions pyglossary/glossary_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
)


class EntryType(typing.Protocol):
class EntryType(typing.Protocol): # noqa: PLR0904
def __init__(self) -> None: ...

def isData(self) -> bool: ...
Expand Down Expand Up @@ -132,7 +132,7 @@ def sort(self) -> None: ...
def close(self) -> None: ...


class GlossaryType(typing.Protocol):
class GlossaryType(typing.Protocol): # noqa: PLR0904

"""
an abstract type class for Glossary class in plugins. it only
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/glossary_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class ConvertArgs:
infoOverride: "dict[str, str] | None" = None


class GlossaryCommon(GlossaryInfo, GlossaryProgress, PluginManager):
class GlossaryCommon(GlossaryInfo, GlossaryProgress, PluginManager): # noqa: PLR0904

"""
The signature of 'convert' method is different in glossary_v2.py
Expand Down
4 changes: 2 additions & 2 deletions pyglossary/io_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
__all__ = ["nullBinaryIO", "nullTextIO"]


class _NullBinaryIO(io.BufferedIOBase):
class _NullBinaryIO(io.BufferedIOBase): # noqa: PLR0904
def __enter__(self, *args):
raise NotImplementedError

Expand Down Expand Up @@ -79,7 +79,7 @@ def writelines(self, lines: "list[bytes]") -> None: # type: ignore
raise NotImplementedError


class _NullTextIO(io.TextIOBase):
class _NullTextIO(io.TextIOBase): # noqa: PLR0904
def __enter__(self, *args):
raise NotImplementedError

Expand Down
77 changes: 38 additions & 39 deletions pyglossary/plugin_prop.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

if TYPE_CHECKING:
import pathlib
from collections.abc import Callable
from typing import Any

from .flags import StrWithDesc
Expand Down Expand Up @@ -65,7 +64,7 @@ class PluginCheckError(Exception):
pass


class PluginProp:
class PluginProp: # noqa: PLR0904
__slots__ = [
"_Reader",
"_ReaderLoaded",
Expand Down Expand Up @@ -305,7 +304,7 @@ def canWrite(self) -> bool:
return self._canWrite

@staticmethod
def getOptionAttrNamesFromClass(rwclass: "type") -> "list[str]":
def _getOptionAttrNamesFromClass(rwclass: "type") -> "list[str]":
nameList = []

for cls in (*rwclass.__bases__, rwclass):
Expand All @@ -321,13 +320,13 @@ def getOptionAttrNamesFromClass(rwclass: "type") -> "list[str]":

return nameList

def getOptionsFromClass(self, rwclass: "type") -> "dict[str, Any]":
def _getOptionsFromClass(self, rwclass: "type") -> "dict[str, Any]":
optionsProp = self.optionsProp
options = odict()
if rwclass is None:
return options

for attrName in self.getOptionAttrNamesFromClass(rwclass):
for attrName in self._getOptionAttrNamesFromClass(rwclass):
name = attrName[1:]
default = getattr(rwclass, attrName)
if name not in optionsProp:
Expand All @@ -352,12 +351,12 @@ def getOptionsFromClass(self, rwclass: "type") -> "dict[str, Any]":

def getReadOptions(self) -> "dict[str, Any]":
if self._readOptions is None:
self._readOptions = self.getOptionsFromClass(self.readerClass)
self._readOptions = self._getOptionsFromClass(self.readerClass)
return self._readOptions

def getWriteOptions(self) -> "dict[str, Any]":
if self._writeOptions is None:
self._writeOptions = self.getOptionsFromClass(self.writerClass)
self._writeOptions = self._getOptionsFromClass(self.writerClass)
return self._writeOptions

@property
Expand Down Expand Up @@ -490,35 +489,35 @@ def checkWriterClass(self) -> bool:

return True

def getReadExtraOptions(self) -> "list[str]": # noqa: F811
cls = self.readerClass
if cls is None:
return []
return self.__class__.getExtraOptionsFromFunc(cls.open, self.name)

def getWriteExtraOptions(self) -> "list[str]": # noqa: F811
cls = self.writerClass
if cls is None:
return []
return self.__class__.getExtraOptionsFromFunc(cls.write, self.name)

@classmethod
def getExtraOptionsFromFunc(
cls: "type",
func: "Callable",
format: str,
) -> "list[str]":
import inspect

extraOptNames = []
for name, param in inspect.signature(func).parameters.items():
if name == "self":
continue
if str(param.default) != "<class 'inspect._empty'>":
extraOptNames.append(name)
continue
if name not in {"filename", "dirname"}:
extraOptNames.append(name)
if extraOptNames:
log.warning(f"{format}: {extraOptNames = }")
return extraOptNames
# def _getReadExtraOptions(self) -> "list[str]": # noqa: F811
# cls = self.readerClass
# if cls is None:
# return []
# return self.__class__.getExtraOptionsFromFunc(cls.open, self.name)

# def _getWriteExtraOptions(self) -> "list[str]": # noqa: F811
# cls = self.writerClass
# if cls is None:
# return []
# return self.__class__.getExtraOptionsFromFunc(cls.write, self.name)

# @classmethod
# def getExtraOptionsFromFunc(
# cls: "type",
# func: "Callable",
# format: str,
# ) -> "list[str]":
# import inspect

# extraOptNames = []
# for name, param in inspect.signature(func).parameters.items():
# if name == "self":
# continue
# if str(param.default) != "<class 'inspect._empty'>":
# extraOptNames.append(name)
# continue
# if name not in {"filename", "dirname"}:
# extraOptNames.append(name)
# if extraOptNames:
# log.warning(f"{format}: {extraOptNames = }")
# return extraOptNames
Loading

0 comments on commit b674a0f

Please sign in to comment.