6
0
mirror of https://github.com/ChristianLight/tutor.git synced 2024-12-04 19:03:39 +00:00

feat: add py.typed for typing extensions

Extensions which use the tutor API need to know that the tutor package
is typed. For that we add the py.typed file.

Also, we fix the signature of get_typed.

See:
https://mypy.readthedocs.io/en/stable/installed_packages.html#installed-packages
This commit is contained in:
Régis Behmo 2022-10-26 11:25:58 +02:00
parent 7eeccfb5f5
commit 1161f925a4
3 changed files with 5 additions and 1 deletions

View File

@ -1,3 +1,4 @@
include requirements/base.in
include requirements/plugins.txt
recursive-include tutor/templates *
include tutor/py.typed

0
tutor/py.typed Normal file
View File

View File

@ -35,7 +35,10 @@ T = t.TypeVar("T")
def get_typed(
config: Config, key: str, expected_type: t.Type[T], default: t.Optional[T] = None
config: t.Dict[str, t.Any],
key: str,
expected_type: t.Type[T],
default: t.Optional[T] = None,
) -> T:
value = config.get(key, default)
if not isinstance(value, expected_type):