Skip to content

Commit 7fa3ac5

Browse files
committed
fix and rebase
1 parent 0ac18fd commit 7fa3ac5

35 files changed

Lines changed: 84 additions & 46 deletions

File tree

‎core/testcontainers/compose/compose.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
from subprocess import CalledProcessError, CompletedProcess
1111
from subprocess import run as subprocess_run
1212
from types import TracebackType
13-
from typing import Any, Callable, Literal, Optional, Self, TypeVar, Union, cast
13+
from typing import Any, Callable, Literal, Optional, TypeVar, Union, cast
14+
15+
from typing_extensions import Self
1416

1517
from testcontainers.core.docker_client import DockerClient, get_docker_host_hostname, is_podman
1618
from testcontainers.core.exceptions import ContainerIsNotRunning, NoSuchPortExposed
@@ -47,7 +49,7 @@ class PublishedPortModel:
4749
PublishedPort: Optional[int] = None
4850
Protocol: Optional[str] = None
4951

50-
def normalize(self) -> Self:
52+
def normalize(self) -> "PublishedPortModel":
5153
url = self.URL
5254

5355
# For SSH-based DOCKER_HOST, local addresses (0.0.0.0, 127.0.0.1, localhost, ::, ::1)

‎core/testcontainers/core/container.py‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
from os import PathLike
88
from socket import socket
99
from types import TracebackType
10-
from typing import TYPE_CHECKING, Any, Optional, Self, TypedDict, Union, cast
10+
from typing import TYPE_CHECKING, Any, Optional, TypedDict, Union, cast
1111

1212
import docker.errors
1313
from docker import version
1414
from docker.models.containers import ExecResult
1515
from docker.types import EndpointConfig
1616
from dotenv import dotenv_values
17-
from typing_extensions import assert_never
17+
from typing_extensions import Self, assert_never
1818

1919
from testcontainers.core.config import ConnectionMode
2020
from testcontainers.core.config import testcontainers_config as c
@@ -403,14 +403,14 @@ class Reaper:
403403
:meta private:
404404
"""
405405

406-
_instance: Optional[Self] = None
406+
_instance: "Optional[Reaper]" = None
407407
_container: Optional[DockerContainer] = None
408408
_socket: Optional[socket] = None
409409

410410
@classmethod
411-
def get_instance(cls) -> Self:
412-
if not Reaper._instance:
413-
Reaper._create_instance()
411+
def get_instance(cls) -> "Reaper":
412+
if Reaper._instance is None:
413+
Reaper._instance = Reaper._create_instance()
414414

415415
return Reaper._instance
416416

@@ -429,7 +429,7 @@ def delete_instance(cls) -> None:
429429
Reaper._instance = None
430430

431431
@classmethod
432-
def _create_instance(cls) -> Self:
432+
def _create_instance(cls) -> "Reaper":
433433
logger.debug(f"Creating new Reaper for session: {SESSION_ID}")
434434

435435
Reaper._container = (

‎core/testcontainers/core/generic.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1111
# License for the specific language governing permissions and limitations
1212
# under the License.
13-
from typing import Any, Optional, Self
13+
from typing import Any, Optional
1414
from urllib.parse import quote
1515

16+
from typing_extensions import Self
17+
1618
from testcontainers.core.container import DockerContainer
1719
from testcontainers.core.exceptions import ContainerStartException
1820
from testcontainers.core.utils import raise_for_deprecated_parameter

‎core/testcontainers/core/image.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from os import PathLike
22
from types import TracebackType
3-
from typing import TYPE_CHECKING, Any, Optional, Self, Union
3+
from typing import TYPE_CHECKING, Any, Optional, Union
4+
5+
from typing_extensions import Self
46

57
from testcontainers.core.docker_client import DockerClient
68
from testcontainers.core.utils import setup_logger

‎core/testcontainers/core/inspect.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
"""Docker Engine API data structures for container inspect responses."""
1515

1616
from dataclasses import dataclass, fields, is_dataclass
17-
from typing import Any, Optional, Self, TypeVar
17+
from typing import Any, Optional, TypeVar
18+
19+
from typing_extensions import Self
1820

1921
_IPT = TypeVar("_IPT")
2022

‎core/testcontainers/core/network.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
# under the License.
1313
import uuid
1414
from types import TracebackType
15-
from typing import TYPE_CHECKING, Any, Optional, Self
15+
from typing import TYPE_CHECKING, Any, Optional
16+
17+
from typing_extensions import Self
1618

1719
from testcontainers.core.docker_client import DockerClient
1820

‎core/testcontainers/core/wait_strategies.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@
3535
import time
3636
from datetime import timedelta
3737
from pathlib import Path
38-
from typing import TYPE_CHECKING, Any, Callable, Optional, Self, Union, cast
38+
from typing import TYPE_CHECKING, Any, Callable, Optional, Union, cast
3939
from urllib.error import HTTPError, URLError
4040
from urllib.request import Request, urlopen
4141

42+
from typing_extensions import Self
43+
4244
from testcontainers.compose import DockerCompose
4345
from testcontainers.core.utils import setup_logger
4446

‎core/testcontainers/socat/socat.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
import random
1414
import socket
1515
import string
16-
from typing import Any, Optional, Self
16+
from typing import Any, Optional
17+
18+
from typing_extensions import Self
1719

1820
from testcontainers.core.container import DockerContainer
1921
from testcontainers.core.waiting_utils import wait_container_is_ready

‎modules/azurite/testcontainers/azurite/__init__.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
# under the License.
1313
import enum
1414
import os
15-
from typing import Optional, Self
15+
from typing import Optional
16+
17+
from typing_extensions import Self
1618

1719
from testcontainers.core.container import DockerContainer
1820
from testcontainers.core.utils import raise_for_deprecated_parameter

‎modules/chroma/testcontainers/chroma/__init__.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from typing import TYPE_CHECKING, Self
1+
from typing import TYPE_CHECKING
22

33
from requests import ConnectionError, get
4+
from typing_extensions import Self
45

56
from testcontainers.core.container import DockerContainer
67
from testcontainers.core.utils import raise_for_deprecated_parameter

0 commit comments

Comments
 (0)