Skip to content

Commit

Permalink
resolving issues raised by ruff (work in progress)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaasRostock committed Oct 23, 2024
1 parent 3b1501a commit 5fc2f67
Show file tree
Hide file tree
Showing 17 changed files with 2,013 additions and 1,949 deletions.
7 changes: 7 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ select = [
"ALL",
]
ignore = [
# Ruff lint rules temporarily ignored, but which should be reactivated and resolved in the future.
"D", # Missing docstrings <- @TODO: reactivate and resolve docstring issues @CLAROS, 2024-10-21
"N999", # Invalid module name <- @TODO: reactivate and resolve @CLAROS, 2024-10-21
"C901", # Function is too complex <- @TODO: reactivate and resolve print statements @CLAROS, 2024-10-21
"PLR0911", # Too many return statements <- @TODO: reactivate and resolve @CLAROS, 2024-10-21
"PLR0912", # Too many branches <- @TODO: reactivate and resolve @CLAROS, 2024-10-21
"PLR0915", # Too many statements <- @TODO: reactivate and resolve @CLAROS, 2024-10-21
# Ruff lint rules considered as too strict and hence ignored
"ANN101", # Missing type annotation for `self` argument in instance methods (NOTE: also listed as deprecated by Ruff)
"ANN102", # Missing type annotation for `cls` argument in class methods (NOTE: also listed as deprecated by Ruff)
Expand Down
20 changes: 9 additions & 11 deletions src/farn/cli/farn.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import sys
from argparse import ArgumentParser
from pathlib import Path
from typing import Tuple, Union

# Remove current directory from Python search path.
# Only through this trick it is possible that the current CLI file 'farn.py'
Expand Down Expand Up @@ -132,12 +131,11 @@ def _argparser() -> argparse.ArgumentParser:
return parser


def main():
def main() -> None:
"""Entry point for console script as configured in setup.cfg.
Runs the command line interface and parses arguments and options entered on the console.
"""

parser = _argparser()
try:
args = parser.parse_args()
Expand All @@ -154,14 +152,14 @@ def main():
log_level_console = "ERROR" if args.quiet else log_level_console
log_level_console = "DEBUG" if args.verbose else log_level_console
# ..to file
log_file: Union[Path, None] = Path(args.log) if args.log else None
log_file: Path | None = Path(args.log) if args.log else None
log_level_file: str = args.log_level
configure_logging(log_level_console, log_file, log_level_file)

farn_dict_file: Path = Path(args.farnDict)
sample: bool = args.sample
generate: bool = args.generate
command: Union[str, None] = args.execute
command: str | None = args.execute
batch: bool = args.batch
test: bool = args.test

Expand Down Expand Up @@ -200,7 +198,7 @@ def main():
)


def _generate_barnsley_fern():
def _generate_barnsley_fern() -> None:
"""
easter egg: Barnsley fern.
Expand All @@ -224,19 +222,19 @@ def _generate_barnsley_fern():
from PIL import Image
from PIL.ImageDraw import ImageDraw

def t1(p: Tuple[float, float]) -> Tuple[float, float]:
def t1(p: tuple[float, float]) -> tuple[float, float]:
"""1%."""
return (0.0, 0.16 * p[1])

def t2(p: Tuple[float, float]) -> Tuple[float, float]:
def t2(p: tuple[float, float]) -> tuple[float, float]:
"""85%."""
return (0.85 * p[0] + 0.04 * p[1], -0.04 * p[0] + 0.85 * p[1] + 1.6)

def t3(p: Tuple[float, float]) -> Tuple[float, float]:
def t3(p: tuple[float, float]) -> tuple[float, float]:
"""7%."""
return (0.2 * p[0] - 0.26 * p[1], 0.23 * p[0] + 0.22 * p[1] + 1.6)

def t4(p: Tuple[float, float]) -> Tuple[float, float]:
def t4(p: tuple[float, float]) -> tuple[float, float]:
"""7%."""
return (-0.15 * p[0] + 0.28 * p[1], 0.26 * p[0] + 0.24 * p[1] + 0.44)

Expand All @@ -245,7 +243,7 @@ def t4(p: Tuple[float, float]) -> Tuple[float, float]:
im = Image.new("RGBA", (x_size, x_size))
draw = ImageDraw(im)

p: Tuple[float, float] = (0, 0)
p: tuple[float, float] = (0, 0)
end = 20000
ii = 0
scale = 100
Expand Down
Loading

0 comments on commit 5fc2f67

Please sign in to comment.