chore: update typing to collections.abc
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
This commit is contained in:
@@ -15,8 +15,8 @@ the results without the `--online` setting.
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import ast
|
import ast
|
||||||
|
from collections.abc import Iterator
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Iterator
|
|
||||||
|
|
||||||
import click
|
import click
|
||||||
import yaml
|
import yaml
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import functools
|
|||||||
import platform as platform_module
|
import platform as platform_module
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
from collections.abc import Set
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
from .typing import Final, Literal, PlatformName, assert_never
|
from .typing import Final, Literal, PlatformName, assert_never
|
||||||
@@ -132,7 +133,7 @@ class Architecture(Enum):
|
|||||||
|
|
||||||
def allowed_architectures_check(
|
def allowed_architectures_check(
|
||||||
platform: PlatformName,
|
platform: PlatformName,
|
||||||
architectures: set[Architecture],
|
architectures: Set[Architecture],
|
||||||
) -> None:
|
) -> None:
|
||||||
allowed_architectures = Architecture.all_archs(platform)
|
allowed_architectures = Architecture.all_archs(platform)
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from collections.abc import Sequence
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Callable, Dict, List, Sequence
|
from typing import Callable, Dict, List # noqa: TID251
|
||||||
|
|
||||||
import bashlex
|
import bashlex
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import dataclasses
|
import dataclasses
|
||||||
from typing import Any, Mapping, Sequence
|
from collections.abc import Mapping, Sequence
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
import bashlex
|
import bashlex
|
||||||
import bashlex.errors
|
import bashlex.errors
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import typing
|
||||||
|
from collections.abc import Callable
|
||||||
from threading import RLock
|
from threading import RLock
|
||||||
from typing import Any, Callable, Generic, TypeVar, overload
|
from typing import Any, Generic, TypeVar
|
||||||
|
|
||||||
__all__ = ["cached_property"]
|
__all__ = ["cached_property"]
|
||||||
|
|
||||||
@@ -24,11 +26,11 @@ class cached_property(Generic[_T]):
|
|||||||
msg = f"Cannot assign the same cached_property to two different names ({self.attrname!r} and {name!r})."
|
msg = f"Cannot assign the same cached_property to two different names ({self.attrname!r} and {name!r})."
|
||||||
raise TypeError(msg)
|
raise TypeError(msg)
|
||||||
|
|
||||||
@overload
|
@typing.overload
|
||||||
def __get__(self, instance: None, owner: type[Any] | None = ...) -> cached_property[_T]:
|
def __get__(self, instance: None, owner: type[Any] | None = ...) -> cached_property[_T]:
|
||||||
...
|
...
|
||||||
|
|
||||||
@overload
|
@typing.overload
|
||||||
def __get__(self, instance: object, owner: type[Any] | None = ...) -> _T:
|
def __get__(self, instance: object, owner: type[Any] | None = ...) -> _T:
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ from __future__ import annotations
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
from collections.abc import Set
|
from collections.abc import Iterator, Set
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path, PurePath, PurePosixPath
|
from pathlib import Path, PurePath, PurePosixPath
|
||||||
from typing import Iterator, Tuple
|
from typing import Tuple
|
||||||
|
|
||||||
from .architecture import Architecture
|
from .architecture import Architecture
|
||||||
from .logger import log
|
from .logger import log
|
||||||
|
|||||||
@@ -8,10 +8,11 @@ import re
|
|||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from collections.abc import Set
|
import typing
|
||||||
|
from collections.abc import Sequence, Set
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Sequence, Tuple, cast
|
from typing import Tuple
|
||||||
|
|
||||||
from filelock import FileLock
|
from filelock import FileLock
|
||||||
|
|
||||||
@@ -55,7 +56,7 @@ def get_macos_version() -> tuple[int, int]:
|
|||||||
"""
|
"""
|
||||||
version_str, _, _ = platform.mac_ver()
|
version_str, _, _ = platform.mac_ver()
|
||||||
version = tuple(map(int, version_str.split(".")[:2]))
|
version = tuple(map(int, version_str.split(".")[:2]))
|
||||||
return cast(Tuple[int, int], version)
|
return typing.cast(Tuple[int, int], version)
|
||||||
|
|
||||||
|
|
||||||
def get_macos_sdks() -> list[str]:
|
def get_macos_sdks() -> list[str]:
|
||||||
|
|||||||
@@ -8,10 +8,12 @@ import shlex
|
|||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
import typing
|
||||||
import uuid
|
import uuid
|
||||||
|
from collections.abc import Sequence
|
||||||
from pathlib import Path, PurePath, PurePosixPath
|
from pathlib import Path, PurePath, PurePosixPath
|
||||||
from types import TracebackType
|
from types import TracebackType
|
||||||
from typing import IO, Dict, Sequence, cast
|
from typing import IO, Dict
|
||||||
|
|
||||||
from cibuildwheel.util import CIProvider, detect_ci_provider
|
from cibuildwheel.util import CIProvider, detect_ci_provider
|
||||||
|
|
||||||
@@ -329,7 +331,7 @@ class OCIContainer:
|
|||||||
capture_output=True,
|
capture_output=True,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return cast(Dict[str, str], env)
|
return typing.cast(Dict[str, str], env)
|
||||||
|
|
||||||
def environment_executor(self, command: list[str], environment: dict[str, str]) -> str:
|
def environment_executor(self, command: list[str], environment: dict[str, str]) -> str:
|
||||||
# used as an EnvironmentExecutor to evaluate commands and capture output
|
# used as an EnvironmentExecutor to evaluate commands and capture output
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ import shlex
|
|||||||
import sys
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
import traceback
|
import traceback
|
||||||
|
import typing
|
||||||
|
from collections.abc import Callable, Generator, Iterator, Mapping, Set
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Callable, Dict, Generator, Iterator, List, Mapping, Union, cast
|
from typing import Any, Dict, List, Union
|
||||||
|
|
||||||
if sys.version_info >= (3, 11):
|
if sys.version_info >= (3, 11):
|
||||||
import tomllib
|
import tomllib
|
||||||
@@ -193,7 +195,7 @@ class OptionsReader:
|
|||||||
*,
|
*,
|
||||||
platform: PlatformName,
|
platform: PlatformName,
|
||||||
env: Mapping[str, str],
|
env: Mapping[str, str],
|
||||||
disallow: dict[str, set[str]] | None = None,
|
disallow: Mapping[str, Set[str]] | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.platform = platform
|
self.platform = platform
|
||||||
self.env = env
|
self.env = env
|
||||||
@@ -462,7 +464,7 @@ class Options:
|
|||||||
print(msg, file=sys.stderr)
|
print(msg, file=sys.stderr)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
container_engine = cast(ContainerEngine, container_engine_str)
|
container_engine = typing.cast(ContainerEngine, container_engine_str)
|
||||||
|
|
||||||
return GlobalOptions(
|
return GlobalOptions(
|
||||||
package_dir=package_dir,
|
package_dir=package_dir,
|
||||||
|
|||||||
+6
-14
@@ -11,23 +11,15 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
import time
|
import time
|
||||||
|
import typing
|
||||||
import urllib.request
|
import urllib.request
|
||||||
|
from collections.abc import Generator, Iterable, Sequence
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
from pathlib import Path, PurePath
|
from pathlib import Path, PurePath
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from typing import (
|
from typing import Any, ClassVar, TextIO, TypeVar
|
||||||
Any,
|
|
||||||
ClassVar,
|
|
||||||
Generator,
|
|
||||||
Iterable,
|
|
||||||
Sequence,
|
|
||||||
TextIO,
|
|
||||||
TypeVar,
|
|
||||||
cast,
|
|
||||||
overload,
|
|
||||||
)
|
|
||||||
|
|
||||||
import bracex
|
import bracex
|
||||||
import certifi
|
import certifi
|
||||||
@@ -107,7 +99,7 @@ CIBW_CACHE_PATH: Final[Path] = Path(
|
|||||||
IS_WIN: Final[bool] = sys.platform.startswith("win")
|
IS_WIN: Final[bool] = sys.platform.startswith("win")
|
||||||
|
|
||||||
|
|
||||||
@overload
|
@typing.overload
|
||||||
def call(
|
def call(
|
||||||
*args: PathOrStr,
|
*args: PathOrStr,
|
||||||
env: dict[str, str] | None = None,
|
env: dict[str, str] | None = None,
|
||||||
@@ -117,7 +109,7 @@ def call(
|
|||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
@overload
|
@typing.overload
|
||||||
def call(
|
def call(
|
||||||
*args: PathOrStr,
|
*args: PathOrStr,
|
||||||
env: dict[str, str] | None = None,
|
env: dict[str, str] | None = None,
|
||||||
@@ -149,7 +141,7 @@ def call(
|
|||||||
result = subprocess.run(args_, check=True, shell=IS_WIN, env=env, cwd=cwd, **kwargs)
|
result = subprocess.run(args_, check=True, shell=IS_WIN, env=env, cwd=cwd, **kwargs)
|
||||||
if not capture_stdout:
|
if not capture_stdout:
|
||||||
return None
|
return None
|
||||||
return cast(str, result.stdout)
|
return typing.cast(str, result.stdout)
|
||||||
|
|
||||||
|
|
||||||
def shell(*commands: str, env: dict[str, str] | None = None, cwd: PathOrStr | None = None) -> None:
|
def shell(*commands: str, env: dict[str, str] | None = None, cwd: PathOrStr | None = None) -> None:
|
||||||
|
|||||||
@@ -6,12 +6,11 @@ import shutil
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
from collections.abc import Set
|
from collections.abc import Sequence, Set
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Sequence
|
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
|
|
||||||
from filelock import FileLock
|
from filelock import FileLock
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ select = [
|
|||||||
"RET", # flake8-return
|
"RET", # flake8-return
|
||||||
"RUF", # Ruff-specific
|
"RUF", # Ruff-specific
|
||||||
"SIM", # flake8-simplify
|
"SIM", # flake8-simplify
|
||||||
|
"TID251", # flake8-tidy-imports.banned-api
|
||||||
"UP", # pyupgrade
|
"UP", # pyupgrade
|
||||||
"YTT", # flake8-2020
|
"YTT", # flake8-2020
|
||||||
"EXE", # flake8-executable
|
"EXE", # flake8-executable
|
||||||
@@ -151,6 +152,12 @@ target-version = "py37"
|
|||||||
typing-modules = ["cibuildwheel.typing"]
|
typing-modules = ["cibuildwheel.typing"]
|
||||||
flake8-unused-arguments.ignore-variadic-names = true
|
flake8-unused-arguments.ignore-variadic-names = true
|
||||||
|
|
||||||
|
[tool.ruff.flake8-tidy-imports.banned-api]
|
||||||
|
"typing.Mapping".msg = "Use collections.abc.Mapping instead."
|
||||||
|
"typing.Callable".msg = "Use collections.abc.Callable instead."
|
||||||
|
"typing.Iterator".msg = "Use collections.abc.Iterator instead."
|
||||||
|
"typing.Sequence".msg = "Use collections.abc.Sequence instead."
|
||||||
|
"typing.Set".msg = "Use collections.abc.Set instead."
|
||||||
|
|
||||||
[tool.ruff.per-file-ignores]
|
[tool.ruff.per-file-ignores]
|
||||||
"unit_test/*" = ["PLC1901"]
|
"unit_test/*" = ["PLC1901"]
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ from __future__ import annotations
|
|||||||
import platform as platform_module
|
import platform as platform_module
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
import typing
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from pathlib import PurePosixPath
|
from pathlib import PurePosixPath
|
||||||
from typing import cast
|
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@@ -52,7 +52,7 @@ def test_build_default_launches(monkeypatch):
|
|||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
||||||
build_in_container = cast(mock.Mock, linux.build_in_container)
|
build_in_container = typing.cast(mock.Mock, linux.build_in_container)
|
||||||
|
|
||||||
assert build_in_container.call_count == 4
|
assert build_in_container.call_count == 4
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ before-all = "true"
|
|||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
||||||
build_in_container = cast(mock.Mock, linux.build_in_container)
|
build_in_container = typing.cast(mock.Mock, linux.build_in_container)
|
||||||
|
|
||||||
assert build_in_container.call_count == 6
|
assert build_in_container.call_count == 6
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user