Skip to content

Commit

Permalink
moved ruff rule SLF001 to ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
Tjalling-dejong committed Dec 3, 2024
1 parent ddf825e commit cac223f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
18 changes: 8 additions & 10 deletions fm2prof/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,13 @@ def _create_logger(self) -> None:
self.__logger.setLevel(logging.DEBUG)

# create formatter
self.__logger.__logformatter = ElapsedFormatter() #noqa: SLF001
self.__logger._Filelogformatter = ElapsedFileFormatter() #noqa: SLF001

self.__logger.__logformatter = ElapsedFormatter()
self.__logger._Filelogformatter = ElapsedFileFormatter()
# create console handler
if TqdmLoggingHandler not in map(type, self.__logger.handlers):
ch = TqdmLoggingHandler()
ch.setLevel(logging.DEBUG)
ch.setFormatter(self.__logger.__logformatter) #noqa: SLF001
self.__logger.addHandler(ch)
ch.setFormatter(self.__logger.__logformatter)

def get_logger(self) -> Logger:
"""Use this method to return logger object."""
Expand Down Expand Up @@ -234,10 +232,10 @@ def set_logger_message(

if header:
self.get_logformatter().set_intro(True)
self.get_logger()._Filelogformatter.set_intro(True) #noqa: SLF001
self.get_logger()._Filelogformatter.set_intro(True)
else:
self.get_logformatter().set_intro(False)
self.get_logger()._Filelogformatter.set_intro(False) #noqa: SLF001
self.get_logger()._Filelogformatter.set_intro(False)

if level.lower() not in ["info", "debug", "warning", "error", "critical"]:
err_msg = f"{level.lower()} is not valid logging level."
Expand Down Expand Up @@ -276,11 +274,11 @@ def finish_log_task(self) -> None:

def get_logformatter(self) -> ElapsedFormatter:
"""Returns log formatter."""
return self.get_logger().__logformatter #noqa: SLF001
return self.get_logger().__logformatter

def get_filelogformatter(self) -> ElapsedFormatter:
"""Returns file log formatter."""
return self.get_logger()._Filelogformatter #noqa: SLF001
return self.get_logger()._Filelogformatter

def set_logfile(self, output_dir: str | Path, filename: str = "fm2prof.log") -> None:
"""Set log file.
Expand All @@ -295,7 +293,7 @@ def set_logfile(self, output_dir: str | Path, filename: str = "fm2prof.log") ->
raise ValueError(err_msg)
fh = logging.FileHandler(Path(output_dir).joinpath(filename), encoding="utf-8")
fh.setLevel(logging.DEBUG)
fh.setFormatter(self.get_logger()._Filelogformatter) #noqa: SLF001
fh.setFormatter(self.get_logger()._Filelogformatter)
self.__logger.addHandler(fh)

def set_inifile(self, inifile: IniFile = None) -> None:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ build-backend = "poetry.core.masonry.api"

[tool.ruff]
line-length = 120
ignore = ["DTZ005", "DTZ001", "FA100"]
ignore = ["DTZ005", "DTZ001", "FA100", "SLF001"]
exclude = ["scripts"]

[tool.ruff.lint]
Expand Down

0 comments on commit cac223f

Please sign in to comment.