mirror of
https://github.com/chatmail/core.git
synced 2026-04-06 07:32:12 +03:00
`deltachat.const` module now defines `__getattr__` and `__dir__` as suggested by https://www.python.org/dev/peps/pep-0562/ mypy detects that `__getattr__` is defined and does not show errors for `DC_*` constants which cannot be detected statically. mypy is added to `tox.ini`, so type check can be run with `tox -e mypy`.
14 lines
282 B
Python
14 lines
282 B
Python
from typing import Any, List
|
|
|
|
from .capi import lib
|
|
|
|
|
|
def __getattr__(name: str) -> Any:
|
|
if name.startswith("DC_"):
|
|
return getattr(lib, name)
|
|
return globals()[name]
|
|
|
|
|
|
def __dir__() -> List[str]:
|
|
return sorted(name for name in dir(lib) if name.startswith("DC_"))
|