Skip to content

Commit dcdc461

Browse files
authored
Merge pull request #20 from tim25651/master
added type hints
2 parents be9b0bc + e47ab1c commit dcdc461

8 files changed

Lines changed: 460 additions & 278 deletions

File tree

.github/workflows/pr.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,7 @@ jobs:
3030
POETRY_VIRTUALENVS_CREATE: false
3131
- name: Check formatting and linting
3232
run: poetry run ruff check
33+
- name: Static type checking
34+
run: poetry run mypy pydpkg/
3335
- name: Test with pytest
3436
run: poetry run pytest tests/

poetry.lock

Lines changed: 191 additions & 106 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pydpkg/base.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
Base class to avoid pylint complaining about duplicate code
33
"""
44

5+
from __future__ import annotations
6+
7+
from typing import Any
8+
59

610
class _Dbase:
711
# pylint: disable=too-few-public-methods
8-
def __getitem__(self, item):
12+
def __getitem__(self, item: str) -> Any:
913
"""Overload getitem to treat the message plus our local
1014
properties as items.
1115
@@ -17,6 +21,6 @@ def __getitem__(self, item):
1721
return getattr(self, item)
1822
except AttributeError:
1923
try:
20-
return self.__getattr__(item)
24+
return self.__getattr__(item) # type: ignore[attr-defined]
2125
except AttributeError as ex:
2226
raise KeyError(item) from ex

0 commit comments

Comments
 (0)