From 021b044977e47c0446f5d888f68ee6f560af4e90 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 | 2 +- 3 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 tutor/py.typed diff --git a/MANIFEST.in b/MANIFEST.in index 4b08baefefa..9b2c42c9331 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 00000000000..e69de29bb2d diff --git a/tutor/types.py b/tutor/types.py index 973f580c316..262ef26c000 100644 --- a/tutor/types.py +++ b/tutor/types.py @@ -35,7 +35,7 @@ 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):