Skip to content

Commit

Permalink
Fix linters
Browse files Browse the repository at this point in the history
  • Loading branch information
bdragon300 committed Oct 20, 2024
1 parent a7a537b commit caff09d
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.12.0
rev: v1.12.1
hooks:
- id: mypy
- repo: https://github.com/PyCQA/pylint
Expand Down
123 changes: 89 additions & 34 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ isort = "~5"
mypy = "~1"
pylint = "~3"
pytest-mock = "^3.14.0"
flake8 = "~5"
flake8-pyproject = "~1"

[tool.pytest.ini_options]
minversion = "6.0"
Expand Down
22 changes: 8 additions & 14 deletions pyzkaccess/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Any,
Callable,
Dict,
Final,
Generic,
Iterable,
Iterator,
Expand All @@ -22,14 +23,15 @@
Tuple,
Type,
TypeVar,
Union, Final, )
Union,
)

import fire
import prettytable
import wrapt
from fire.core import FireError

from pyzkaccess import ZK100, ZK200, ZK400, ZKAccess, UnsupportedPlatformError, ZKModel
from pyzkaccess import ZK100, ZK200, ZK400, UnsupportedPlatformError, ZKAccess, ZKModel
from pyzkaccess._setup import setup
from pyzkaccess.device_data.model import Model, models_registry
from pyzkaccess.device_data.queryset import QuerySet
Expand Down Expand Up @@ -892,9 +894,7 @@ def table(self, name: str) -> Query:
'TemplateV10'
"""
if name not in models_registry:
raise FireError(
f"Unknown table '{name}', possible values are: {list(sorted(models_registry.keys()))}"
)
raise FireError(f"Unknown table '{name}', possible values are: {list(sorted(models_registry.keys()))}")
qs = self._zk.table(name)
table_cls = qs._table_cls
formatter = BaseFormatter.get_formatter(OPT_IO_FORMAT)(DATA_IN, DATA_OUT, table_cls.fields_mapping().keys())
Expand Down Expand Up @@ -922,9 +922,7 @@ def read_raw(self, name: str, *, buffer_size=32768):
Default is 32Kb
"""
if name not in models_registry:
raise FireError(
f"Unknown table '{name}', possible values are: {list(sorted(models_registry.keys()))}"
)
raise FireError(f"Unknown table '{name}', possible values are: {list(sorted(models_registry.keys()))}")
table_cls = models_registry[name]
formatter = BaseFormatter.get_formatter(OPT_IO_FORMAT)(DATA_IN, DATA_OUT, table_cls.fields_mapping().values())
converter = TextConverter(formatter)
Expand All @@ -946,9 +944,7 @@ def write_raw(self, name: str):
'TemplateV10'
"""
if name not in models_registry:
raise FireError(
f"Unknown table '{name}', possible values are: {list(sorted(models_registry.keys()))}"
)
raise FireError(f"Unknown table '{name}', possible values are: {list(sorted(models_registry.keys()))}")
table_cls = models_registry[name]
formatter = BaseFormatter.get_formatter(OPT_IO_FORMAT)(DATA_IN, DATA_OUT, table_cls.fields_mapping().values())
converter = TextConverter(formatter)
Expand Down Expand Up @@ -1068,9 +1064,7 @@ def __call__(self, *, format: str = "ascii_table", file: str = None, dllpath: st
if format not in io_formats:
# Workaround of "Could not consume arg" message appearing
# instead of exception message problem
sys.stderr.write(
f"ERROR: Unknown format '{format}', available are: {list(sorted(io_formats.keys()))}\n"
)
sys.stderr.write(f"ERROR: Unknown format '{format}', available are: {list(sorted(io_formats.keys()))}\n")
raise FireError(f"Unknown format '{format}', available are: {list(sorted(io_formats.keys()))}")

global OPT_IO_FORMAT
Expand Down
2 changes: 0 additions & 2 deletions tests/test_exceptions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import sys

import pytest

from pyzkaccess.exceptions import ZKSDKError
Expand Down
3 changes: 1 addition & 2 deletions tests/test_setup_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import sys
from pathlib import Path
from unittest.mock import Mock
from venv import create

import pytest

Expand Down Expand Up @@ -241,7 +240,7 @@ def test_fetch_and_extract__on_invalid_path__should_exit(self) -> None:
_fetch_and_extract("invalid")

assert exc.value.code == 3
assert f"File or directory 'invalid' not found" in str(exc.value)
assert "File or directory 'invalid' not found" in str(exc.value)


class TestInstallDlls:
Expand Down

0 comments on commit caff09d

Please sign in to comment.