Skip to content

Commit

Permalink
Use TYPE_CHECKING flag to avoid importing from typing_extensions
Browse files Browse the repository at this point in the history
…at run time (#877)
  • Loading branch information
edgarrmondragon authored Jul 18, 2024
1 parent 9e9f648 commit e2af544
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES/876.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use ``TYPE_CHECKING`` flag to avoid importing from ``typing_extensions`` at run time
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Byeongjun Park
Cecil Tonglet
Christian Barra
Danny Song
Edgar Ramírez Mondragón
eevelweezel
Gaopeiliang
Greg Guthe
Expand Down
9 changes: 8 additions & 1 deletion aiodocker/types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from __future__ import annotations

import sys
from typing import (
TYPE_CHECKING,
Mapping,
Protocol,
Sequence,
Expand All @@ -9,7 +11,12 @@
Union,
)

from typing_extensions import TypeAlias

if TYPE_CHECKING:
if sys.version_info < (3, 10):
from typing_extensions import TypeAlias
else:
from typing import TypeAlias


_T_co = TypeVar("_T_co", covariant=True)
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ ci = [
"yarl==1.9.4",
]
dev = [
"async-timeout==4.0.3",
"codecov==2.1.13",
"mypy==1.10.1",
"packaging==24.1",
Expand Down
9 changes: 8 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import traceback
import uuid
from typing import (
TYPE_CHECKING,
Any,
AsyncIterator,
Awaitable,
Expand All @@ -15,13 +16,19 @@

import pytest
from packaging.version import parse as parse_version
from typing_extensions import TypeAlias

from aiodocker.containers import DockerContainer
from aiodocker.docker import Docker
from aiodocker.exceptions import DockerError


if TYPE_CHECKING:
if sys.version_info < (3, 10):
from typing_extensions import TypeAlias
else:
from typing import TypeAlias


API_VERSIONS = {
"17.06": "v1.30",
"17.09": "v1.32",
Expand Down

0 comments on commit e2af544

Please sign in to comment.