Skip to content

Commit

Permalink
always import from typing_extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
tdstein committed Dec 16, 2024
1 parent 8eb0486 commit 93e75eb
Show file tree
Hide file tree
Showing 38 changed files with 60 additions and 53 deletions.
2 changes: 1 addition & 1 deletion examples/connect/databricks/fastapi/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/posit/connect/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/posit/connect/_api_call.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/posit/connect/_json.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/posit/connect/_utils.py
Original file line number Diff line number Diff line change
@@ -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]:
Expand Down
3 changes: 2 additions & 1 deletion src/posit/connect/bundles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions src/posit/connect/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/posit/connect/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Client configuration."""

import os
from typing import Optional

from typing_extensions import Optional

from . import urls

Expand Down
9 changes: 6 additions & 3 deletions src/posit/connect/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/posit/connect/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/posit/connect/cursors.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/posit/connect/env.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/posit/connect/environments.py
Original file line number Diff line number Diff line change
@@ -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,
)
Expand Down
3 changes: 2 additions & 1 deletion src/posit/connect/errors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
from typing import Any

from typing_extensions import Any


class ClientError(Exception):
Expand Down
2 changes: 1 addition & 1 deletion src/posit/connect/external/databricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/posit/connect/external/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/posit/connect/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/posit/connect/jobs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import (
from typing_extensions import (
Iterable,
Literal,
Protocol,
Expand Down
2 changes: 1 addition & 1 deletion src/posit/connect/metrics/shiny_usage.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/posit/connect/metrics/usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/posit/connect/metrics/visits.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/posit/connect/oauth/associations.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/posit/connect/oauth/integrations.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/posit/connect/oauth/oauth.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/posit/connect/oauth/sessions.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/posit/connect/paginator.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/posit/connect/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/posit/connect/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import posixpath
import warnings
from abc import ABC
from typing import (

from typing_extensions import (
TYPE_CHECKING,
Any,
Hashable,
Expand Down
4 changes: 1 addition & 3 deletions src/posit/connect/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/posit/connect/tags.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/posit/connect/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import overload
from typing_extensions import overload

from . import resources

Expand Down
12 changes: 9 additions & 3 deletions src/posit/connect/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/posit/connect/vanities.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/posit/connect/variants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List
from typing_extensions import List

from .context import Context
from .resources import BaseResource, Resources
Expand Down
2 changes: 1 addition & 1 deletion tests/posit/connect/external/test_databricks.py
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down
3 changes: 1 addition & 2 deletions tests/posit/connect/test_jobs.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 2 additions & 1 deletion tests/posit/connect/test_resources.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down

0 comments on commit 93e75eb

Please sign in to comment.