From 93e75eb1dee36c314db0b9381fdf25919e0e8a3f Mon Sep 17 00:00:00 2001 From: tdstein Date: Mon, 16 Dec 2024 14:46:57 -0500 Subject: [PATCH] always import from typing_extensions --- examples/connect/databricks/fastapi/app.py | 2 +- .../posit/connect/test_content_item_permissions.py | 3 +-- src/posit/connect/_api.py | 3 ++- src/posit/connect/_api_call.py | 3 ++- src/posit/connect/_json.py | 2 +- src/posit/connect/_utils.py | 2 +- src/posit/connect/bundles.py | 3 ++- src/posit/connect/client.py | 3 +-- src/posit/connect/config.py | 3 ++- src/posit/connect/content.py | 9 ++++++--- src/posit/connect/context.py | 2 +- src/posit/connect/cursors.py | 3 ++- src/posit/connect/env.py | 2 +- src/posit/connect/environments.py | 2 +- src/posit/connect/errors.py | 3 ++- src/posit/connect/external/databricks.py | 2 +- src/posit/connect/external/snowflake.py | 2 +- src/posit/connect/groups.py | 2 +- src/posit/connect/jobs.py | 2 +- src/posit/connect/metrics/shiny_usage.py | 2 +- src/posit/connect/metrics/usage.py | 3 +-- src/posit/connect/metrics/visits.py | 2 +- src/posit/connect/oauth/associations.py | 2 +- src/posit/connect/oauth/integrations.py | 2 +- src/posit/connect/oauth/oauth.py | 3 +-- src/posit/connect/oauth/sessions.py | 2 +- src/posit/connect/paginator.py | 3 ++- src/posit/connect/permissions.py | 3 +-- src/posit/connect/resources.py | 3 ++- src/posit/connect/system.py | 4 +--- src/posit/connect/tags.py | 3 +-- src/posit/connect/tasks.py | 2 +- src/posit/connect/users.py | 12 +++++++++--- src/posit/connect/vanities.py | 4 +--- src/posit/connect/variants.py | 2 +- tests/posit/connect/external/test_databricks.py | 2 +- tests/posit/connect/test_jobs.py | 3 +-- tests/posit/connect/test_resources.py | 3 ++- 38 files changed, 60 insertions(+), 53 deletions(-) diff --git a/examples/connect/databricks/fastapi/app.py b/examples/connect/databricks/fastapi/app.py index ed01f41c..a3e49e6a 100644 --- a/examples/connect/databricks/fastapi/app.py +++ b/examples/connect/databricks/fastapi/app.py @@ -3,11 +3,11 @@ from __future__ import annotations import os -from typing import TYPE_CHECKING, Annotated from databricks import sql from databricks.sdk.core import Config, databricks_cli from fastapi import FastAPI, Header +from typing_extensions import TYPE_CHECKING, Annotated from posit.connect.external.databricks import PositCredentialsStrategy diff --git a/integration/tests/posit/connect/test_content_item_permissions.py b/integration/tests/posit/connect/test_content_item_permissions.py index 518178d5..9f3ee04b 100644 --- a/integration/tests/posit/connect/test_content_item_permissions.py +++ b/integration/tests/posit/connect/test_content_item_permissions.py @@ -1,8 +1,7 @@ from __future__ import annotations -from typing import TYPE_CHECKING - import pytest +from typing_extensions import TYPE_CHECKING from posit import connect diff --git a/src/posit/connect/_api.py b/src/posit/connect/_api.py index 29325158..f45dc0ee 100644 --- a/src/posit/connect/_api.py +++ b/src/posit/connect/_api.py @@ -4,7 +4,8 @@ from __future__ import annotations from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, Optional, cast + +from typing_extensions import TYPE_CHECKING, Any, Optional, cast from ._api_call import ApiCallMixin, get_api from ._json import Jsonifiable, JsonifiableDict, ResponseAttrs diff --git a/src/posit/connect/_api_call.py b/src/posit/connect/_api_call.py index 56ce70f6..0de5f0ba 100644 --- a/src/posit/connect/_api_call.py +++ b/src/posit/connect/_api_call.py @@ -1,7 +1,8 @@ from __future__ import annotations import posixpath -from typing import TYPE_CHECKING, Protocol + +from typing_extensions import TYPE_CHECKING, Protocol if TYPE_CHECKING: from ._json import Jsonifiable diff --git a/src/posit/connect/_json.py b/src/posit/connect/_json.py index 62f28f82..85f331fa 100644 --- a/src/posit/connect/_json.py +++ b/src/posit/connect/_json.py @@ -1,4 +1,4 @@ -from typing import Dict, List, Tuple, TypeVar, Union +from typing_extensions import Dict, List, Tuple, TypeVar, Union # Implemented in https://github.com/posit-dev/py-shiny/blob/415ced034e6c500adda524abb7579731c32088b5/shiny/types.py#L357-L386 # Table from: https://github.com/python/cpython/blob/df1eec3dae3b1eddff819fd70f58b03b3fbd0eda/Lib/json/encoder.py#L77-L95 diff --git a/src/posit/connect/_utils.py b/src/posit/connect/_utils.py index 26842bbc..e279f3b7 100644 --- a/src/posit/connect/_utils.py +++ b/src/posit/connect/_utils.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Any +from typing_extensions import Any def drop_none(x: dict[str, Any]) -> dict[str, Any]: diff --git a/src/posit/connect/bundles.py b/src/posit/connect/bundles.py index 3363e3bb..5dba4ee4 100644 --- a/src/posit/connect/bundles.py +++ b/src/posit/connect/bundles.py @@ -3,7 +3,8 @@ from __future__ import annotations import io -from typing import TYPE_CHECKING, List + +from typing_extensions import TYPE_CHECKING, List from . import resources, tasks diff --git a/src/posit/connect/client.py b/src/posit/connect/client.py index f0f5c3a1..6ef22c21 100644 --- a/src/posit/connect/client.py +++ b/src/posit/connect/client.py @@ -2,9 +2,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, overload - from requests import Response, Session +from typing_extensions import TYPE_CHECKING, overload from . import hooks, me from .auth import Auth diff --git a/src/posit/connect/config.py b/src/posit/connect/config.py index 59d03c87..500bda73 100644 --- a/src/posit/connect/config.py +++ b/src/posit/connect/config.py @@ -1,7 +1,8 @@ """Client configuration.""" import os -from typing import Optional + +from typing_extensions import Optional from . import urls diff --git a/src/posit/connect/content.py b/src/posit/connect/content.py index dd900f6d..f7a3fdb8 100644 --- a/src/posit/connect/content.py +++ b/src/posit/connect/content.py @@ -4,18 +4,21 @@ import posixpath import time -from typing import ( + +from typing_extensions import ( TYPE_CHECKING, Any, List, Literal, + NotRequired, Optional, + Required, + TypedDict, + Unpack, cast, overload, ) -from typing_extensions import NotRequired, Required, TypedDict, Unpack - from . import tasks from ._api import ApiDictEndpoint, JsonifiableDict from .bundles import Bundles diff --git a/src/posit/connect/context.py b/src/posit/connect/context.py index ec7ff55a..dbc456b7 100644 --- a/src/posit/connect/context.py +++ b/src/posit/connect/context.py @@ -2,9 +2,9 @@ import functools import weakref -from typing import TYPE_CHECKING, Protocol from packaging.version import Version +from typing_extensions import TYPE_CHECKING, Protocol if TYPE_CHECKING: from .client import Client diff --git a/src/posit/connect/cursors.py b/src/posit/connect/cursors.py index 22f406e1..414d965d 100644 --- a/src/posit/connect/cursors.py +++ b/src/posit/connect/cursors.py @@ -1,7 +1,8 @@ from __future__ import annotations from dataclasses import dataclass -from typing import TYPE_CHECKING, Any, Generator, List + +from typing_extensions import TYPE_CHECKING, Any, Generator, List if TYPE_CHECKING: from .context import Context diff --git a/src/posit/connect/env.py b/src/posit/connect/env.py index 5ca26cd2..f801dc00 100644 --- a/src/posit/connect/env.py +++ b/src/posit/connect/env.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Iterator, List, Mapping, MutableMapping, Optional +from typing_extensions import TYPE_CHECKING, Any, Iterator, List, Mapping, MutableMapping, Optional from .resources import Resources diff --git a/src/posit/connect/environments.py b/src/posit/connect/environments.py index d2cc85e5..1fb78b59 100644 --- a/src/posit/connect/environments.py +++ b/src/posit/connect/environments.py @@ -1,11 +1,11 @@ from __future__ import annotations from abc import abstractmethod -from typing import Protocol from typing_extensions import ( List, Literal, + Protocol, TypedDict, runtime_checkable, ) diff --git a/src/posit/connect/errors.py b/src/posit/connect/errors.py index 8e8bf8db..e7ef7997 100644 --- a/src/posit/connect/errors.py +++ b/src/posit/connect/errors.py @@ -1,5 +1,6 @@ import json -from typing import Any + +from typing_extensions import Any class ClientError(Exception): diff --git a/src/posit/connect/external/databricks.py b/src/posit/connect/external/databricks.py index e73c5f71..0c9ad886 100644 --- a/src/posit/connect/external/databricks.py +++ b/src/posit/connect/external/databricks.py @@ -6,9 +6,9 @@ """ import abc -from typing import Callable, Dict, Optional import requests +from typing_extensions import Callable, Dict, Optional from ..client import Client from ..oauth import Credentials diff --git a/src/posit/connect/external/snowflake.py b/src/posit/connect/external/snowflake.py index 7f5ec923..1bc5dd74 100644 --- a/src/posit/connect/external/snowflake.py +++ b/src/posit/connect/external/snowflake.py @@ -3,7 +3,7 @@ NOTE: The APIs in this module are provided as a convenience and are subject to breaking changes. """ -from typing import Optional +from typing_extensions import Optional from ..client import Client from .external import is_local diff --git a/src/posit/connect/groups.py b/src/posit/connect/groups.py index fa5cf9dd..36f530e4 100644 --- a/src/posit/connect/groups.py +++ b/src/posit/connect/groups.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Optional, overload +from typing_extensions import TYPE_CHECKING, List, Optional, overload from .paginator import Paginator from .resources import BaseResource, Resources diff --git a/src/posit/connect/jobs.py b/src/posit/connect/jobs.py index 8797686b..959c1dab 100644 --- a/src/posit/connect/jobs.py +++ b/src/posit/connect/jobs.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import ( +from typing_extensions import ( Iterable, Literal, Protocol, diff --git a/src/posit/connect/metrics/shiny_usage.py b/src/posit/connect/metrics/shiny_usage.py index a5240f4f..d9657d9f 100644 --- a/src/posit/connect/metrics/shiny_usage.py +++ b/src/posit/connect/metrics/shiny_usage.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import List, overload +from typing_extensions import List, overload from ..cursors import CursorPaginator from ..resources import BaseResource, Resources diff --git a/src/posit/connect/metrics/usage.py b/src/posit/connect/metrics/usage.py index b9eac649..b513a52f 100644 --- a/src/posit/connect/metrics/usage.py +++ b/src/posit/connect/metrics/usage.py @@ -2,9 +2,8 @@ from __future__ import annotations -from typing import List, overload - from requests.sessions import Session as Session +from typing_extensions import List, overload from .. import resources from . import shiny_usage, visits diff --git a/src/posit/connect/metrics/visits.py b/src/posit/connect/metrics/visits.py index ea88dfb6..503d14af 100644 --- a/src/posit/connect/metrics/visits.py +++ b/src/posit/connect/metrics/visits.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import List, overload +from typing_extensions import List, overload from ..cursors import CursorPaginator from ..resources import BaseResource, Resources diff --git a/src/posit/connect/oauth/associations.py b/src/posit/connect/oauth/associations.py index 44723dfc..5d20db02 100644 --- a/src/posit/connect/oauth/associations.py +++ b/src/posit/connect/oauth/associations.py @@ -1,6 +1,6 @@ """OAuth association resources.""" -from typing import List +from typing_extensions import List from ..context import Context from ..resources import BaseResource, Resources diff --git a/src/posit/connect/oauth/integrations.py b/src/posit/connect/oauth/integrations.py index 3e3259e9..7dca39eb 100644 --- a/src/posit/connect/oauth/integrations.py +++ b/src/posit/connect/oauth/integrations.py @@ -1,6 +1,6 @@ """OAuth integration resources.""" -from typing import List, Optional, overload +from typing_extensions import List, Optional, overload from ..resources import BaseResource, Resources from .associations import IntegrationAssociations diff --git a/src/posit/connect/oauth/oauth.py b/src/posit/connect/oauth/oauth.py index 90df7270..efec4395 100644 --- a/src/posit/connect/oauth/oauth.py +++ b/src/posit/connect/oauth/oauth.py @@ -1,9 +1,8 @@ from __future__ import annotations import os -from typing import TYPE_CHECKING, Optional -from typing_extensions import TypedDict +from typing_extensions import TYPE_CHECKING, Optional, TypedDict from ..resources import Resources from .integrations import Integrations diff --git a/src/posit/connect/oauth/sessions.py b/src/posit/connect/oauth/sessions.py index fae3981b..e0db5829 100644 --- a/src/posit/connect/oauth/sessions.py +++ b/src/posit/connect/oauth/sessions.py @@ -1,6 +1,6 @@ """OAuth session resources.""" -from typing import List, Optional, overload +from typing_extensions import List, Optional, overload from ..resources import BaseResource, Resources diff --git a/src/posit/connect/paginator.py b/src/posit/connect/paginator.py index 75b224d3..0252e66f 100644 --- a/src/posit/connect/paginator.py +++ b/src/posit/connect/paginator.py @@ -1,7 +1,8 @@ from __future__ import annotations from dataclasses import dataclass -from typing import TYPE_CHECKING, Generator, List + +from typing_extensions import TYPE_CHECKING, Generator, List if TYPE_CHECKING: from .context import Context diff --git a/src/posit/connect/permissions.py b/src/posit/connect/permissions.py index 211decc2..4b029cb5 100644 --- a/src/posit/connect/permissions.py +++ b/src/posit/connect/permissions.py @@ -2,9 +2,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Optional, overload - from requests.sessions import Session as Session +from typing_extensions import TYPE_CHECKING, List, Optional, overload from .resources import BaseResource, Resources diff --git a/src/posit/connect/resources.py b/src/posit/connect/resources.py index 70cffc53..7095c8fa 100644 --- a/src/posit/connect/resources.py +++ b/src/posit/connect/resources.py @@ -3,7 +3,8 @@ import posixpath import warnings from abc import ABC -from typing import ( + +from typing_extensions import ( TYPE_CHECKING, Any, Hashable, diff --git a/src/posit/connect/system.py b/src/posit/connect/system.py index 446eff4f..46353fd5 100644 --- a/src/posit/connect/system.py +++ b/src/posit/connect/system.py @@ -2,9 +2,7 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Literal, overload - -from typing_extensions import TypedDict, Unpack +from typing_extensions import TYPE_CHECKING, List, Literal, TypedDict, Unpack, overload from .context import ContextManager from .resources import Active diff --git a/src/posit/connect/tags.py b/src/posit/connect/tags.py index 502a7b49..0ff303ae 100644 --- a/src/posit/connect/tags.py +++ b/src/posit/connect/tags.py @@ -1,9 +1,8 @@ from __future__ import annotations from abc import ABC, abstractmethod -from typing import TYPE_CHECKING, Optional, overload -from typing_extensions import NotRequired, TypedDict, Unpack +from typing_extensions import TYPE_CHECKING, NotRequired, Optional, TypedDict, Unpack, overload from .context import Context, ContextManager from .resources import Active diff --git a/src/posit/connect/tasks.py b/src/posit/connect/tasks.py index 8360304d..ac6b2931 100644 --- a/src/posit/connect/tasks.py +++ b/src/posit/connect/tasks.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import overload +from typing_extensions import overload from . import resources diff --git a/src/posit/connect/users.py b/src/posit/connect/users.py index 334617a5..a925df90 100644 --- a/src/posit/connect/users.py +++ b/src/posit/connect/users.py @@ -2,9 +2,15 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List, Literal - -from typing_extensions import NotRequired, Required, TypedDict, Unpack +from typing_extensions import ( + TYPE_CHECKING, + List, + Literal, + NotRequired, + Required, + TypedDict, + Unpack, +) from . import me from .content import Content diff --git a/src/posit/connect/vanities.py b/src/posit/connect/vanities.py index 5a483054..3ab9f4f2 100644 --- a/src/posit/connect/vanities.py +++ b/src/posit/connect/vanities.py @@ -1,6 +1,4 @@ -from typing import Callable, List, Optional - -from typing_extensions import NotRequired, Required, TypedDict, Unpack +from typing_extensions import Callable, List, NotRequired, Optional, Required, TypedDict, Unpack from .context import Context from .errors import ClientError diff --git a/src/posit/connect/variants.py b/src/posit/connect/variants.py index 9970c70e..2e518fb0 100644 --- a/src/posit/connect/variants.py +++ b/src/posit/connect/variants.py @@ -1,4 +1,4 @@ -from typing import List +from typing_extensions import List from .context import Context from .resources import BaseResource, Resources diff --git a/tests/posit/connect/external/test_databricks.py b/tests/posit/connect/external/test_databricks.py index 9861b907..134911b1 100644 --- a/tests/posit/connect/external/test_databricks.py +++ b/tests/posit/connect/external/test_databricks.py @@ -1,9 +1,9 @@ import base64 -from typing import Dict from unittest.mock import patch import pytest import responses +from typing_extensions import Dict from posit.connect import Client from posit.connect.external.databricks import ( diff --git a/tests/posit/connect/test_jobs.py b/tests/posit/connect/test_jobs.py index b2463d98..802dd850 100644 --- a/tests/posit/connect/test_jobs.py +++ b/tests/posit/connect/test_jobs.py @@ -1,8 +1,7 @@ -from typing import TYPE_CHECKING - import pytest import responses from requests.exceptions import HTTPError +from typing_extensions import TYPE_CHECKING from posit.connect.client import Client diff --git a/tests/posit/connect/test_resources.py b/tests/posit/connect/test_resources.py index a17d252b..52536b96 100644 --- a/tests/posit/connect/test_resources.py +++ b/tests/posit/connect/test_resources.py @@ -1,8 +1,9 @@ import warnings -from typing import Optional from unittest import mock from unittest.mock import Mock +from typing_extensions import Optional + from posit.connect.resources import BaseResource config = Mock()