From 1c8302277f325d8c2b82f83f0fb682efffd2e01e Mon Sep 17 00:00:00 2001 From: tdstein Date: Tue, 12 Nov 2024 16:42:31 -0500 Subject: [PATCH] refactor: revert to typing-extensions library --- src/posit/connect/_typing_extensions.py | 42 ------------------------- src/posit/connect/content.py | 3 +- src/posit/connect/jobs.py | 3 +- src/posit/connect/oauth/oauth.py | 3 +- src/posit/connect/users.py | 3 +- src/posit/connect/vanities.py | 3 +- 6 files changed, 10 insertions(+), 47 deletions(-) delete mode 100644 src/posit/connect/_typing_extensions.py diff --git a/src/posit/connect/_typing_extensions.py b/src/posit/connect/_typing_extensions.py deleted file mode 100644 index 951bb118..00000000 --- a/src/posit/connect/_typing_extensions.py +++ /dev/null @@ -1,42 +0,0 @@ -# # Within file flags to ignore unused imports -# flake8: noqa: F401 -# pyright: reportUnusedImport=false - -# Extended from https://github.com/posit-dev/py-shiny/blob/main/shiny/_typing_extensions.py - -__all__ = ( - "Required", - "NotRequired", - "Self", - "TypedDict", - "Unpack", -) - - -import sys - -if sys.version_info >= (3, 10): - from typing import TypeGuard -else: - from typing_extensions import TypeGuard - -# Even though TypedDict is available in Python 3.8, because it's used with NotRequired, -# they should both come from the same typing module. -# https://peps.python.org/pep-0655/#usage-in-python-3-11 -if sys.version_info >= (3, 11): - from typing import NotRequired, Required, Self, TypedDict, Unpack -else: - from typing_extensions import ( - NotRequired, - Required, - Self, - TypedDict, - Unpack, - ) - - -# The only purpose of the following line is so that pyright will put all of the -# conditional imports into the .pyi file when generating type stubs. Without this line, -# pyright will not include the above imports in the generated .pyi file, and it will -# result in a lot of red squiggles in user code. -_: "TypeGuard | NotRequired | Required | TypedDict | Self | Unpack" # type:ignore diff --git a/src/posit/connect/content.py b/src/posit/connect/content.py index a5498757..404867b7 100644 --- a/src/posit/connect/content.py +++ b/src/posit/connect/content.py @@ -15,9 +15,10 @@ overload, ) +from typing_extensions import NotRequired, Required, TypedDict, Unpack + from . import tasks from ._api import ApiDictEndpoint, JsonifiableDict -from ._typing_extensions import NotRequired, Required, TypedDict, Unpack from .bundles import Bundles from .context import Context from .env import EnvVars diff --git a/src/posit/connect/jobs.py b/src/posit/connect/jobs.py index bcf97092..96fff315 100644 --- a/src/posit/connect/jobs.py +++ b/src/posit/connect/jobs.py @@ -1,7 +1,8 @@ import posixpath from typing import Any, Literal, Optional, overload -from ._typing_extensions import NotRequired, Required, TypedDict, Unpack +from typing_extensions import NotRequired, Required, TypedDict, Unpack + from .context import Context from .resources import Active, ActiveFinderMethods, ActiveSequence, Resource diff --git a/src/posit/connect/oauth/oauth.py b/src/posit/connect/oauth/oauth.py index 18cd7f5c..306170b8 100644 --- a/src/posit/connect/oauth/oauth.py +++ b/src/posit/connect/oauth/oauth.py @@ -2,7 +2,8 @@ from typing import Optional -from .._typing_extensions import TypedDict +from typing_extensions import TypedDict + from ..resources import ResourceParameters, Resources from .integrations import Integrations from .sessions import Sessions diff --git a/src/posit/connect/users.py b/src/posit/connect/users.py index cc206da8..dd9c6833 100644 --- a/src/posit/connect/users.py +++ b/src/posit/connect/users.py @@ -4,8 +4,9 @@ from typing import List, Literal +from typing_extensions import NotRequired, Required, TypedDict, Unpack + from . import me -from ._typing_extensions import NotRequired, Required, TypedDict, Unpack from .content import Content from .paginator import Paginator from .resources import Resource, ResourceParameters, Resources diff --git a/src/posit/connect/vanities.py b/src/posit/connect/vanities.py index c0345eed..5f9a1679 100644 --- a/src/posit/connect/vanities.py +++ b/src/posit/connect/vanities.py @@ -1,6 +1,7 @@ from typing import Callable, List, Optional -from ._typing_extensions import NotRequired, Required, TypedDict, Unpack +from typing_extensions import NotRequired, Required, TypedDict, Unpack + from .errors import ClientError from .resources import Resource, ResourceParameters, Resources