Skip to content

Commit

Permalink
Address lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
allenporter committed Aug 7, 2024
1 parent c60d320 commit e1e9b30
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ repos:
language: script
types: [python]
require_serial: true
files: ^custom_components/
files: ^home_assistant_datasets/
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
Expand Down
16 changes: 8 additions & 8 deletions home_assistant_datasets/tool/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@


def create_arguments(
parser: argparse.ArgumentParser, subcmds: dict[str, types.ModuleType]
parser: argparse._SubParsersAction[argparse.ArgumentParser],
subcmds: dict[str, types.ModuleType],
) -> None:
"""Recursively add sub commands/submodules and arguments to the parser"""
for name, module in subcmds.items():
if not hasattr(module, "SUBCMDS"):
module.create_arguments(parser.add_parser(name))
continue

cmd_parser = parser.add_parser(name)
subparsers = cmd_parser.add_subparsers(
dest="subaction", help="Sub Action", required=True
subparsers: argparse._SubParsersAction[argparse.ArgumentParser] = (
cmd_parser.add_subparsers(
dest="subaction", help="Sub Action", required=True
)
)
create_arguments(subparsers, module.SUBCMDS)
for inner_name, inner_module in module.SUBCMDS.items():
inner_module.create_arguments(subparsers.add_parser(inner_name))


def get_base_arg_parser() -> argparse.ArgumentParser:
Expand Down
9 changes: 7 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ collect-area-data = "home_assistant_datasets.tools.collect_area_data:main"
home-assistant-datasets = "home_assistant_datasets.tool.__main__:main"

[tool.mypy]
exclude = ["setup.py", "venv/", "home_assistant_datasets/tool/archive_evals/"]
exclude = [
"setup\\.py",
"venv",
"home_assistant_datasets/tool/archive_evals",
"custom_components/",
]
platform = "linux"
show_error_codes = true
follow_imports = "normal"
Expand All @@ -40,7 +45,7 @@ no_implicit_optional = true
warn_incomplete_stub = true
warn_redundant_casts = true
warn_unused_configs = true
warn_unused_ignores = true
warn_unused_ignores = false
disable_error_code = ["import-untyped", "var-annotated", "import-not-found"]
extra_checks = false
check_untyped_defs = true
Expand Down
12 changes: 12 additions & 0 deletions script/run-mypy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -o errexit

# other common virtualenvs
my_path=$(git rev-parse --show-toplevel)

if [ -f "${my_path}/venv/bin/activate" ]; then
. "${my_path}/venv/bin/activate"
fi

mypy home_assistant_datasets

0 comments on commit e1e9b30

Please sign in to comment.