From 1161f925a454482f4f5dd7fa04f17be5ce2435c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Wed, 26 Oct 2022 11:25:58 +0200 Subject: [PATCH] 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 --- MANIFEST.in | 1 + tutor/py.typed | 0 tutor/types.py | 5 ++++- 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 tutor/py.typed diff --git a/MANIFEST.in b/MANIFEST.in index 4b08baefef..9b2c42c933 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,4 @@ include requirements/base.in include requirements/plugins.txt recursive-include tutor/templates * +include tutor/py.typed diff --git a/tutor/py.typed b/tutor/py.typed new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tutor/types.py b/tutor/types.py index 973f580c31..e2a4469f52 100644 --- a/tutor/types.py +++ b/tutor/types.py @@ -35,7 +35,10 @@ def cast_config(config: t.Any) -> Config: 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):