Skip to content

Commit

Permalink
feat: add py.typed for typing extensions
Browse files Browse the repository at this point in the history
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
  • Loading branch information
regisb committed Oct 26, 2022
1 parent 7eeccfb commit 1161f92
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include requirements/base.in
include requirements/plugins.txt
recursive-include tutor/templates *
include tutor/py.typed
Empty file added tutor/py.typed
Empty file.
5 changes: 4 additions & 1 deletion tutor/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 1161f92

Please sign in to comment.