From 4b4e96476ba598208a54fb0a88a65e7fb0ba6b9e Mon Sep 17 00:00:00 2001 From: Wessel Bruinsma Date: Sun, 21 Jan 2024 10:54:49 +0100 Subject: [PATCH] Also export `Annotated` --- plum/typing.py | 5 ++++- tests/advanced/test_annotated.py | 8 +------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/plum/typing.py b/plum/typing.py index f2fbf92..50d338c 100644 --- a/plum/typing.py +++ b/plum/typing.py @@ -1,6 +1,6 @@ import sys -__all__ = ["get_type_hints", "get_origin", "get_args"] +__all__ = ["get_type_hints", "get_origin", "get_args", "Annotated"] # Before Python 3.9, e.g. `get_type_hints` does not include the keyword argument # `include_extras`, so we take `get_type_hints` from `typing_extensions` instead, @@ -12,6 +12,8 @@ get_type_hints = typing_extensions.get_type_hints get_origin = typing_extensions.get_origin get_args = typing_extensions.get_args + Annotated = typing_extensions.Annotated + else: # pragma: specific no cover 3.8 import typing @@ -19,3 +21,4 @@ get_type_hints = typing.get_type_hints get_origin = typing.get_origin get_args = typing.get_args + Annotated = typing.Annotated diff --git a/tests/advanced/test_annotated.py b/tests/advanced/test_annotated.py index 5fac2ec..7f3264d 100644 --- a/tests/advanced/test_annotated.py +++ b/tests/advanced/test_annotated.py @@ -1,14 +1,8 @@ -import sys - -if sys.version_info < (3, 9): - from typing_extensions import Annotated -else: - from typing import Annotated - import pytest from beartype.vale import Is from plum import Dispatcher, NotFoundLookupError +from plum.typing import Annotated def test_simple_annotated():