configure flake8 and fix issues

This commit is contained in:
Patrick Moessler 2023-05-21 22:13:38 +02:00
parent 4f8c27a529
commit d089e11345
3 changed files with 32 additions and 8 deletions

20
poetry.lock generated
View file

@ -94,6 +94,24 @@ mccabe = ">=0.7.0,<0.8.0"
pycodestyle = ">=2.10.0,<2.11.0" pycodestyle = ">=2.10.0,<2.11.0"
pyflakes = ">=3.0.0,<3.1.0" pyflakes = ">=3.0.0,<3.1.0"
[[package]]
name = "flake8-pyproject"
version = "1.2.3"
description = "Flake8 plug-in loading the configuration from pyproject.toml"
category = "dev"
optional = false
python-versions = ">= 3.6"
files = [
{file = "flake8_pyproject-1.2.3-py3-none-any.whl", hash = "sha256:6249fe53545205af5e76837644dc80b4c10037e73a0e5db87ff562d75fb5bd4a"},
]
[package.dependencies]
Flake8 = ">=5"
TOMLi = {version = "*", markers = "python_version < \"3.11\""}
[package.extras]
dev = ["pyTest", "pyTest-cov"]
[[package]] [[package]]
name = "mccabe" name = "mccabe"
version = "0.7.0" version = "0.7.0"
@ -369,4 +387,4 @@ files = [
[metadata] [metadata]
lock-version = "2.0" lock-version = "2.0"
python-versions = "^3.9" python-versions = "^3.9"
content-hash = "b90de4dbcb9039b01369909dd0a6cf26b2346671b8907ccbbe5bbea6a06a6182" content-hash = "bbed92f250e97d898bbff9948aa49a22308abedc4f9f5dd165c94e9af1972bae"

View file

@ -7,8 +7,8 @@ readme = "README.md"
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.9" python = "^3.9"
spidev = "^3.6" spidev = { version = "^3.6", "platform" = "linux" }
mfrc522 = "^0.0.7" mfrc522 = { version = "^0.0.7", platform = "linux" }
pydantic = "^1.10.7" pydantic = "^1.10.7"
python-mpd2 = "^3.1.0" python-mpd2 = "^3.1.0"
@ -17,7 +17,13 @@ python-mpd2 = "^3.1.0"
black = "^23.3.0" black = "^23.3.0"
mypy = "^1.3.0" mypy = "^1.3.0"
flake8 = "^6.0.0" flake8 = "^6.0.0"
flake8-pyproject = "^1.2.3"
[build-system] [build-system]
requires = ["poetry-core"] requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api" build-backend = "poetry.core.masonry.api"
[tool.flake8]
max-line-length = 88
select = ['C', 'E', 'F', 'W', 'B', 'B950']
extend-ignore = ['E203', 'E501', 'W503']

View file

@ -2,7 +2,7 @@
RFID/NFC-based sleep time audio player. """ RFID/NFC-based sleep time audio player. """
from typing import Literal, Optional, Dict, Any, List, Union from typing import Literal, Optional, Dict, List
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
import logging import logging
@ -146,7 +146,7 @@ class Player:
def read_burst(self) -> Optional[int]: def read_burst(self) -> Optional[int]:
tag_id: Optional[int] = None tag_id: Optional[int] = None
for _ in range(10): for _ in range(10):
tag_id = self.reader.read_id_no_block() # type:ignore tag_id: Optional[int] = self.reader.read_id_no_block()
if tag_id is not None: if tag_id is not None:
return tag_id return tag_id
return None return None
@ -290,7 +290,7 @@ class MpdRenderer(Renderer):
def __init__(self) -> None: def __init__(self) -> None:
super().__init__() super().__init__()
self.mpd = MPDClient() # type:ignore self.mpd: MPDClient = MPDClient()
self.mpd.timeout = 10 self.mpd.timeout = 10
self.mpd.connect("/var/run/mpd/socket") self.mpd.connect("/var/run/mpd/socket")
self.mpd.clear() self.mpd.clear()
@ -342,7 +342,7 @@ def main(media_path: str, renderer_type: str) -> None:
else: else:
renderer = DebugRenderer() renderer = DebugRenderer()
player = Player(media_path=media_path, renderer=renderer) player = Player(media_path=media_path, renderer=renderer)
log.info('sleepywaves ready.') log.info("sleepywaves ready.")
try: try:
while True: while True:
player.process() player.process()
@ -363,7 +363,7 @@ if __name__ == "__main__":
) )
parser.add_argument( parser.add_argument(
"--log", "--log",
choices=list(log_levels) + [l.lower() for l in log_levels], choices=list(log_levels) + [lv.lower() for lv in log_levels],
default="WARNING", default="WARNING",
help="log level", help="log level",
) )