diff --git a/bin/bump_version.py b/bin/bump_version.py index 71792113..41895a19 100755 --- a/bin/bump_version.py +++ b/bin/bump_version.py @@ -5,8 +5,6 @@ # /// -from __future__ import annotations - import os import subprocess import sys diff --git a/bin/inspect_all_known_projects.py b/bin/inspect_all_known_projects.py index ad2c6365..60688c4b 100755 --- a/bin/inspect_all_known_projects.py +++ b/bin/inspect_all_known_projects.py @@ -11,8 +11,6 @@ This will cache the results to all_known_setup.yaml; you can reprint the results without the `--online` setting. """ -from __future__ import annotations - import ast from collections.abc import Iterable, Iterator from pathlib import Path diff --git a/bin/make_dependency_update_pr.py b/bin/make_dependency_update_pr.py index 5482a847..0d46aada 100755 --- a/bin/make_dependency_update_pr.py +++ b/bin/make_dependency_update_pr.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -from __future__ import annotations import os import subprocess diff --git a/bin/projects.py b/bin/projects.py index 0278af5b..7414be96 100755 --- a/bin/projects.py +++ b/bin/projects.py @@ -17,8 +17,6 @@ Suggested usage: git diff """ -from __future__ import annotations - import builtins import functools import textwrap @@ -28,7 +26,7 @@ from collections.abc import Iterable, Mapping, Sequence from datetime import datetime from io import StringIO from pathlib import Path -from typing import Any, TextIO +from typing import Any, Self, TextIO import click import yaml @@ -85,7 +83,7 @@ class Project: name_len = len(self.name) + 4 self.__class__.NAME = max(self.__class__.NAME, name_len) - def __lt__(self, other: Project) -> bool: + def __lt__(self, other: Self) -> bool: if self.online: return self.num_stars < other.num_stars else: diff --git a/bin/run_example_ci_configs.py b/bin/run_example_ci_configs.py index 7e8d226a..c7a5b871 100755 --- a/bin/run_example_ci_configs.py +++ b/bin/run_example_ci_configs.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -from __future__ import annotations import os import shutil diff --git a/bin/run_tests.py b/bin/run_tests.py index 264cf267..e4ea6311 100755 --- a/bin/run_tests.py +++ b/bin/run_tests.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -from __future__ import annotations import argparse import os diff --git a/bin/sample_build.py b/bin/sample_build.py index 9e8e6420..41371da1 100755 --- a/bin/sample_build.py +++ b/bin/sample_build.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -from __future__ import annotations import argparse import os diff --git a/bin/update_docker.py b/bin/update_docker.py index b90a0f71..11c3de18 100755 --- a/bin/update_docker.py +++ b/bin/update_docker.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -from __future__ import annotations import configparser from dataclasses import dataclass diff --git a/bin/update_how_it_works_image.py b/bin/update_how_it_works_image.py index 7f55326f..504c9bc4 100755 --- a/bin/update_how_it_works_image.py +++ b/bin/update_how_it_works_image.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -from __future__ import annotations import subprocess import sys diff --git a/bin/update_nodejs.py b/bin/update_nodejs.py index 8a08274a..3f9eb526 100755 --- a/bin/update_nodejs.py +++ b/bin/update_nodejs.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -from __future__ import annotations import difflib import logging diff --git a/bin/update_pythons.py b/bin/update_pythons.py index 69416627..035acbd9 100755 --- a/bin/update_pythons.py +++ b/bin/update_pythons.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -from __future__ import annotations import copy import difflib diff --git a/bin/update_readme_changelog.py b/bin/update_readme_changelog.py index 65756902..024a2337 100755 --- a/bin/update_readme_changelog.py +++ b/bin/update_readme_changelog.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -from __future__ import annotations import re import sys diff --git a/bin/update_virtualenv.py b/bin/update_virtualenv.py index dffdb256..c6cd1b0c 100755 --- a/bin/update_virtualenv.py +++ b/bin/update_virtualenv.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -from __future__ import annotations import difflib import logging diff --git a/cibuildwheel/__init__.py b/cibuildwheel/__init__.py index 413fd1d6..0ca05961 100644 --- a/cibuildwheel/__init__.py +++ b/cibuildwheel/__init__.py @@ -1,3 +1 @@ -from __future__ import annotations - __version__ = "2.22.0" diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 22eb11e8..c1bfc098 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import argparse import contextlib import dataclasses diff --git a/cibuildwheel/architecture.py b/cibuildwheel/architecture.py index 6a67c013..1c08cc8b 100644 --- a/cibuildwheel/architecture.py +++ b/cibuildwheel/architecture.py @@ -1,13 +1,12 @@ -from __future__ import annotations - import platform as platform_module import re import shutil import subprocess import sys +import typing from collections.abc import Set from enum import StrEnum, auto -from typing import Final, Literal, assert_never +from typing import Final, Literal from .typing import PlatformName @@ -38,6 +37,7 @@ def _check_aarch32_el0() -> bool: return check.returncode == 0 and check.stdout.startswith("armv") +@typing.final class Architecture(StrEnum): # mac/linux archs x86_64 = auto() @@ -62,7 +62,7 @@ class Architecture(StrEnum): wasm32 = auto() @staticmethod - def parse_config(config: str, platform: PlatformName) -> set[Architecture]: + def parse_config(config: str, platform: PlatformName) -> "set[Architecture]": result = set() for arch_str in re.split(r"[\s,]+", config): if arch_str == "auto": @@ -82,7 +82,7 @@ class Architecture(StrEnum): return result @staticmethod - def native_arch(platform: PlatformName) -> Architecture | None: + def native_arch(platform: PlatformName) -> "Architecture | None": if platform == "pyodide": return Architecture.wasm32 @@ -112,7 +112,7 @@ class Architecture(StrEnum): return native_architecture @staticmethod - def auto_archs(platform: PlatformName) -> set[Architecture]: + def auto_archs(platform: PlatformName) -> "set[Architecture]": native_arch = Architecture.native_arch(platform) if native_arch is None: return set() # can't build anything on this platform @@ -131,7 +131,7 @@ class Architecture(StrEnum): return result @staticmethod - def all_archs(platform: PlatformName) -> set[Architecture]: + def all_archs(platform: PlatformName) -> "set[Architecture]": all_archs_map = { "linux": { Architecture.x86_64, @@ -148,7 +148,7 @@ class Architecture(StrEnum): return all_archs_map[platform] @staticmethod - def bitness_archs(platform: PlatformName, bitness: Literal["64", "32"]) -> set[Architecture]: + def bitness_archs(platform: PlatformName, bitness: Literal["64", "32"]) -> "set[Architecture]": archs_32 = {Architecture.i686, Architecture.x86, Architecture.armv7l} auto_archs = Architecture.auto_archs(platform) @@ -156,7 +156,7 @@ class Architecture(StrEnum): return auto_archs - archs_32 if bitness == "32": return auto_archs & archs_32 - assert_never(bitness) + typing.assert_never(bitness) def allowed_architectures_check( diff --git a/cibuildwheel/bashlex_eval.py b/cibuildwheel/bashlex_eval.py index 74966539..6656d0a4 100644 --- a/cibuildwheel/bashlex_eval.py +++ b/cibuildwheel/bashlex_eval.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import subprocess from collections.abc import ( Callable, diff --git a/cibuildwheel/ci.py b/cibuildwheel/ci.py index d3af6e93..a7ba04ee 100644 --- a/cibuildwheel/ci.py +++ b/cibuildwheel/ci.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import os import re from enum import Enum diff --git a/cibuildwheel/environment.py b/cibuildwheel/environment.py index e4018b91..d5a0796d 100644 --- a/cibuildwheel/environment.py +++ b/cibuildwheel/environment.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import dataclasses from collections.abc import Mapping, Sequence from typing import Any, Protocol diff --git a/cibuildwheel/extra.py b/cibuildwheel/extra.py index 9cb6dd55..774447c3 100644 --- a/cibuildwheel/extra.py +++ b/cibuildwheel/extra.py @@ -2,8 +2,6 @@ These are utilities for the `/bin` scripts, not for the `cibuildwheel` program. """ -from __future__ import annotations - from collections.abc import Mapping, Sequence from io import StringIO from typing import Protocol diff --git a/cibuildwheel/frontend.py b/cibuildwheel/frontend.py index f5ddad63..8e6a2897 100644 --- a/cibuildwheel/frontend.py +++ b/cibuildwheel/frontend.py @@ -1,10 +1,8 @@ -from __future__ import annotations - import shlex import typing from collections.abc import Sequence from dataclasses import dataclass -from typing import Literal, get_args +from typing import Literal, Self, get_args from .logger import log from .util.helpers import parse_key_value_string @@ -17,8 +15,8 @@ class BuildFrontendConfig: name: BuildFrontendName args: Sequence[str] = () - @staticmethod - def from_config_string(config_string: str) -> BuildFrontendConfig: + @classmethod + def from_config_string(cls, config_string: str) -> Self: config_dict = parse_key_value_string(config_string, ["name"], ["args"]) name = " ".join(config_dict["name"]) if name not in get_args(BuildFrontendName): @@ -29,7 +27,7 @@ class BuildFrontendConfig: name = typing.cast(BuildFrontendName, name) args = config_dict.get("args") or [] - return BuildFrontendConfig(name=name, args=args) + return cls(name=name, args=args) def options_summary(self) -> str | dict[str, str]: if not self.args: diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index 88fd4ba7..65886727 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import contextlib import subprocess import sys diff --git a/cibuildwheel/logger.py b/cibuildwheel/logger.py index 4b7df5c6..48b0c89a 100644 --- a/cibuildwheel/logger.py +++ b/cibuildwheel/logger.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import codecs import os import re @@ -40,6 +38,32 @@ PLATFORM_IDENTIFIER_DESCRIPTIONS: Final[dict[str, str]] = { } +class Colors: + def __init__(self, *, enabled: bool) -> None: + self.red = "\033[31m" if enabled else "" + self.green = "\033[32m" if enabled else "" + self.yellow = "\033[33m" if enabled else "" + self.blue = "\033[34m" if enabled else "" + self.cyan = "\033[36m" if enabled else "" + self.bright_red = "\033[91m" if enabled else "" + self.bright_green = "\033[92m" if enabled else "" + self.white = "\033[37m\033[97m" if enabled else "" + self.gray = "\033[38;5;244m" if enabled else "" + + self.bg_grey = "\033[48;5;235m" if enabled else "" + + self.bold = "\033[1m" if enabled else "" + self.faint = "\033[2m" if enabled else "" + + self.end = "\033[0m" if enabled else "" + + +class Symbols: + def __init__(self, *, unicode: bool) -> None: + self.done = "✓" if unicode else "done" + self.error = "✕" if unicode else "failed" + + class Logger: fold_mode: str colors_enabled: bool @@ -229,32 +253,6 @@ def build_description_from_identifier(identifier: str) -> str: return build_description -class Colors: - def __init__(self, *, enabled: bool) -> None: - self.red = "\033[31m" if enabled else "" - self.green = "\033[32m" if enabled else "" - self.yellow = "\033[33m" if enabled else "" - self.blue = "\033[34m" if enabled else "" - self.cyan = "\033[36m" if enabled else "" - self.bright_red = "\033[91m" if enabled else "" - self.bright_green = "\033[92m" if enabled else "" - self.white = "\033[37m\033[97m" if enabled else "" - self.gray = "\033[38;5;244m" if enabled else "" - - self.bg_grey = "\033[48;5;235m" if enabled else "" - - self.bold = "\033[1m" if enabled else "" - self.faint = "\033[2m" if enabled else "" - - self.end = "\033[0m" if enabled else "" - - -class Symbols: - def __init__(self, *, unicode: bool) -> None: - self.done = "✓" if unicode else "done" - self.error = "✕" if unicode else "failed" - - def file_supports_color(file_obj: IO[AnyStr]) -> bool: """ Returns True if the running system's terminal supports color. diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index e501b6df..a4b0e790 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import functools import inspect import os diff --git a/cibuildwheel/oci_container.py b/cibuildwheel/oci_container.py index 92548849..3a4a4995 100644 --- a/cibuildwheel/oci_container.py +++ b/cibuildwheel/oci_container.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import io import json import os @@ -44,8 +42,8 @@ class OCIContainerEngineConfig: create_args: tuple[str, ...] = field(default_factory=tuple) disable_host_mount: bool = False - @staticmethod - def from_config_string(config_string: str) -> OCIContainerEngineConfig: + @classmethod + def from_config_string(cls, config_string: str) -> Self: config_dict = parse_key_value_string( config_string, ["name"], @@ -75,9 +73,7 @@ class OCIContainerEngineConfig: else: create_args = [arg for arg in create_args if not arg.startswith("--platform=")] - return OCIContainerEngineConfig( - name=name, create_args=tuple(create_args), disable_host_mount=disable_host_mount - ) + return cls(name=name, create_args=tuple(create_args), disable_host_mount=disable_host_mount) def options_summary(self) -> str | dict[str, str]: if not self.create_args: diff --git a/cibuildwheel/options.py b/cibuildwheel/options.py index 2a193f5c..232e5c96 100644 --- a/cibuildwheel/options.py +++ b/cibuildwheel/options.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import collections import configparser import contextlib @@ -12,7 +10,7 @@ import textwrap import tomllib from collections.abc import Callable, Generator, Iterable, Mapping, Sequence, Set from pathlib import Path -from typing import Any, Final, Literal, assert_never +from typing import Any, Final, Literal, Self, assert_never from packaging.specifiers import SpecifierSet @@ -64,9 +62,9 @@ class CommandLineArguments: debug_traceback: bool enable: list[str] - @staticmethod - def defaults() -> CommandLineArguments: - return CommandLineArguments( + @classmethod + def defaults(cls) -> Self: + return cls( platform="auto", allow_empty=False, archs=None, @@ -138,6 +136,12 @@ SettingTable = Mapping[str, SettingLeaf | SettingList] SettingValue = SettingTable | SettingList | SettingLeaf +class InheritRule(enum.Enum): + NONE = enum.auto() + APPEND = enum.auto() + PREPEND = enum.auto() + + @dataclasses.dataclass(frozen=True) class Override: select_pattern: str @@ -272,12 +276,6 @@ class EnvironmentFormat(OptionFormat): return f"{before} {after}" -class InheritRule(enum.Enum): - NONE = enum.auto() - APPEND = enum.auto() - PREPEND = enum.auto() - - def _resolve_cascade( *pairs: tuple[SettingValue | None, InheritRule], ignore_empty: bool = False, @@ -847,8 +845,8 @@ class Options: deprecated_selectors("CIBW_TEST_SKIP", test_selector.skip_config) @functools.cached_property - def defaults(self) -> Options: - return Options( + def defaults(self) -> Self: + return self.__class__( platform=self.platform, command_line_arguments=CommandLineArguments.defaults(), env={}, diff --git a/cibuildwheel/projectfiles.py b/cibuildwheel/projectfiles.py index d2fd635e..3fcebe53 100644 --- a/cibuildwheel/projectfiles.py +++ b/cibuildwheel/projectfiles.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import ast import configparser import contextlib diff --git a/cibuildwheel/pyodide.py b/cibuildwheel/pyodide.py index 3bdb6451..332be935 100644 --- a/cibuildwheel/pyodide.py +++ b/cibuildwheel/pyodide.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import functools import os import shutil diff --git a/cibuildwheel/schema.py b/cibuildwheel/schema.py index 63b936a1..ef8f603b 100644 --- a/cibuildwheel/schema.py +++ b/cibuildwheel/schema.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import json from typing import Any diff --git a/cibuildwheel/selector.py b/cibuildwheel/selector.py index 622a0376..1f417b7e 100644 --- a/cibuildwheel/selector.py +++ b/cibuildwheel/selector.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import fnmatch import itertools from dataclasses import dataclass diff --git a/cibuildwheel/typing.py b/cibuildwheel/typing.py index 026deeaa..87923c1e 100644 --- a/cibuildwheel/typing.py +++ b/cibuildwheel/typing.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import os import typing from typing import Final, Literal, Protocol diff --git a/cibuildwheel/util/cmd.py b/cibuildwheel/util/cmd.py index e02288e2..fcf72581 100644 --- a/cibuildwheel/util/cmd.py +++ b/cibuildwheel/util/cmd.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import os import shlex import shutil diff --git a/cibuildwheel/util/file.py b/cibuildwheel/util/file.py index 4a59a7e0..e38da01e 100644 --- a/cibuildwheel/util/file.py +++ b/cibuildwheel/util/file.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import os import shutil import ssl diff --git a/cibuildwheel/util/helpers.py b/cibuildwheel/util/helpers.py index ffe8b11a..dbef452c 100644 --- a/cibuildwheel/util/helpers.py +++ b/cibuildwheel/util/helpers.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import itertools import os import re diff --git a/cibuildwheel/util/packaging.py b/cibuildwheel/util/packaging.py index c4e14f21..3d284820 100644 --- a/cibuildwheel/util/packaging.py +++ b/cibuildwheel/util/packaging.py @@ -1,8 +1,6 @@ -from __future__ import annotations - from collections.abc import Mapping, MutableMapping, Sequence from pathlib import Path, PurePath -from typing import Any, Literal, TypeVar +from typing import Any, Literal, Self, TypeVar from packaging.utils import parse_wheel_filename @@ -15,9 +13,9 @@ class DependencyConstraints: assert base_file_path.exists() self.base_file_path = base_file_path.resolve() - @staticmethod - def with_defaults() -> DependencyConstraints: - return DependencyConstraints(base_file_path=resources.CONSTRAINTS) + @classmethod + def with_defaults(cls) -> Self: + return cls(base_file_path=resources.CONSTRAINTS) def get_for_python_version( self, version: str, *, variant: Literal["python", "pyodide"] = "python" diff --git a/cibuildwheel/util/resources.py b/cibuildwheel/util/resources.py index 781f92db..7e78bc88 100644 --- a/cibuildwheel/util/resources.py +++ b/cibuildwheel/util/resources.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import tomllib from pathlib import Path from typing import Final diff --git a/cibuildwheel/venv.py b/cibuildwheel/venv.py index 71b29fee..53c03446 100644 --- a/cibuildwheel/venv.py +++ b/cibuildwheel/venv.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import contextlib import functools import os diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 217a6d87..d07d0707 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import os import platform as platform_module import shutil diff --git a/docs/main.py b/docs/main.py index 66066fa2..15d42cbb 100644 --- a/docs/main.py +++ b/docs/main.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import os import subprocess import sysconfig diff --git a/noxfile.py b/noxfile.py index 836acc5a..235d15fc 100755 --- a/noxfile.py +++ b/noxfile.py @@ -15,8 +15,6 @@ Tags: See sessions with `nox -l` """ -from __future__ import annotations - import os import shutil import sys diff --git a/test/conftest.py b/test/conftest.py index 13b0882a..8c0c9504 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import json import subprocess from collections.abc import Generator diff --git a/test/test_0_basic.py b/test/test_0_basic.py index e3910908..317e876d 100644 --- a/test/test_0_basic.py +++ b/test/test_0_basic.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import textwrap import pytest diff --git a/test/test_abi_variants.py b/test/test_abi_variants.py index 11bea544..23cd3de6 100644 --- a/test/test_abi_variants.py +++ b/test/test_abi_variants.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import textwrap from . import test_projects, utils diff --git a/test/test_before_all.py b/test/test_before_all.py index ea59104e..a46031ee 100644 --- a/test/test_before_all.py +++ b/test/test_before_all.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import subprocess import textwrap diff --git a/test/test_before_build.py b/test/test_before_build.py index 3aea640c..c817c87c 100644 --- a/test/test_before_build.py +++ b/test/test_before_build.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import subprocess import textwrap diff --git a/test/test_before_test.py b/test/test_before_test.py index 59da3135..8a33a808 100644 --- a/test/test_before_test.py +++ b/test/test_before_test.py @@ -1,5 +1,3 @@ -from __future__ import annotations - from . import test_projects, utils before_test_project = test_projects.new_c_project() diff --git a/test/test_build_skip.py b/test/test_build_skip.py index 3bfc3a9c..ad7d6f9d 100644 --- a/test/test_build_skip.py +++ b/test/test_build_skip.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import textwrap from . import test_projects, utils diff --git a/test/test_container_engine.py b/test/test_container_engine.py index 3bd6d9bc..4503b3b4 100644 --- a/test/test_container_engine.py +++ b/test/test_container_engine.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import pytest from . import test_projects, utils diff --git a/test/test_container_images.py b/test/test_container_images.py index fb55469f..60517a0f 100644 --- a/test/test_container_images.py +++ b/test/test_container_images.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import platform import textwrap diff --git a/test/test_cpp_standards.py b/test/test_cpp_standards.py index 31d2b721..bb884ad8 100644 --- a/test/test_cpp_standards.py +++ b/test/test_cpp_standards.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import os import jinja2 diff --git a/test/test_custom_repair_wheel.py b/test/test_custom_repair_wheel.py index 56dc059f..bd22d634 100644 --- a/test/test_custom_repair_wheel.py +++ b/test/test_custom_repair_wheel.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import subprocess from contextlib import nullcontext as does_not_raise diff --git a/test/test_dependency_versions.py b/test/test_dependency_versions.py index 54d39467..2cb8a583 100644 --- a/test/test_dependency_versions.py +++ b/test/test_dependency_versions.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import re import textwrap from pathlib import Path diff --git a/test/test_emscripten.py b/test/test_emscripten.py index e7d08398..897cd67f 100644 --- a/test/test_emscripten.py +++ b/test/test_emscripten.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import shutil import sys import textwrap diff --git a/test/test_emulation.py b/test/test_emulation.py index 118b34ac..a8926c0b 100644 --- a/test/test_emulation.py +++ b/test/test_emulation.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import itertools import subprocess diff --git a/test/test_environment.py b/test/test_environment.py index 9b741ceb..4f8a3170 100644 --- a/test/test_environment.py +++ b/test/test_environment.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import os import subprocess import sys diff --git a/test/test_from_sdist.py b/test/test_from_sdist.py index edb446ae..3bb7926d 100644 --- a/test/test_from_sdist.py +++ b/test/test_from_sdist.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import os import subprocess import sys diff --git a/test/test_linux_python.py b/test/test_linux_python.py index 7b642916..c4e7f4e5 100644 --- a/test/test_linux_python.py +++ b/test/test_linux_python.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import platform import subprocess diff --git a/test/test_macos_archs.py b/test/test_macos_archs.py index 8450bdd9..52811f79 100644 --- a/test/test_macos_archs.py +++ b/test/test_macos_archs.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import platform import subprocess diff --git a/test/test_manylinuxXXXX_only.py b/test/test_manylinuxXXXX_only.py index 3fac02d9..41e78ad3 100644 --- a/test/test_manylinuxXXXX_only.py +++ b/test/test_manylinuxXXXX_only.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import platform import textwrap diff --git a/test/test_musllinux_X_Y_only.py b/test/test_musllinux_X_Y_only.py index 0ddd3d2b..9438821a 100644 --- a/test/test_musllinux_X_Y_only.py +++ b/test/test_musllinux_X_Y_only.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import textwrap import pytest diff --git a/test/test_pep518.py b/test/test_pep518.py index b1d99e8d..2147520f 100644 --- a/test/test_pep518.py +++ b/test/test_pep518.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import textwrap from . import test_projects, utils diff --git a/test/test_projects/__init__.py b/test/test_projects/__init__.py index 2d8da665..d6bed818 100644 --- a/test/test_projects/__init__.py +++ b/test/test_projects/__init__.py @@ -1,5 +1,3 @@ -from __future__ import annotations - from .base import TestProject from .c import new_c_project diff --git a/test/test_projects/__main__.py b/test/test_projects/__main__.py index 155c375c..c7c72583 100644 --- a/test/test_projects/__main__.py +++ b/test/test_projects/__main__.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import importlib import subprocess import sys diff --git a/test/test_projects/base.py b/test/test_projects/base.py index 99ccc8b3..dd8f2ce2 100644 --- a/test/test_projects/base.py +++ b/test/test_projects/base.py @@ -1,7 +1,5 @@ -from __future__ import annotations - from pathlib import Path -from typing import Any +from typing import Any, Self import jinja2 @@ -37,8 +35,8 @@ class TestProject: f.write(content) - def copy(self) -> TestProject: - other = TestProject() + def copy(self) -> Self: + other = self.__class__() other.files = self.files.copy() other.template_context = self.template_context.copy() return other diff --git a/test/test_projects/c.py b/test/test_projects/c.py index cea72bdf..05882ec1 100644 --- a/test/test_projects/c.py +++ b/test/test_projects/c.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import jinja2 from .base import TestProject diff --git a/test/test_pure_wheel.py b/test/test_pure_wheel.py index 256afa1b..d309d8a9 100644 --- a/test/test_pure_wheel.py +++ b/test/test_pure_wheel.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import subprocess import pytest diff --git a/test/test_ssl.py b/test/test_ssl.py index 9c35650e..5283a59d 100644 --- a/test/test_ssl.py +++ b/test/test_ssl.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import textwrap from . import test_projects, utils diff --git a/test/test_subdir_package.py b/test/test_subdir_package.py index 66533970..2675ef2e 100644 --- a/test/test_subdir_package.py +++ b/test/test_subdir_package.py @@ -1,5 +1,3 @@ -from __future__ import annotations - from pathlib import Path import jinja2 diff --git a/test/test_testing.py b/test/test_testing.py index 486afe6d..e35e7e0f 100644 --- a/test/test_testing.py +++ b/test/test_testing.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import inspect import os import subprocess diff --git a/test/test_troubleshooting.py b/test/test_troubleshooting.py index e647bca6..7039c268 100644 --- a/test/test_troubleshooting.py +++ b/test/test_troubleshooting.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import subprocess import pytest diff --git a/test/test_wheel_tag.py b/test/test_wheel_tag.py index 1f179ffe..580481ff 100644 --- a/test/test_wheel_tag.py +++ b/test/test_wheel_tag.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import pytest from . import test_projects, utils diff --git a/test/test_windows.py b/test/test_windows.py index 46f4cbb8..142fccf2 100644 --- a/test/test_windows.py +++ b/test/test_windows.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import os import subprocess import textwrap diff --git a/test/utils.py b/test/utils.py index 21543b87..3081cf1d 100644 --- a/test/utils.py +++ b/test/utils.py @@ -4,8 +4,6 @@ Utility functions used by the cibuildwheel tests. This file is added to the PYTHONPATH in the test runner at bin/run_test.py. """ -from __future__ import annotations - import os import platform as pm import subprocess diff --git a/unit_test/architecture_test.py b/unit_test/architecture_test.py index 4bb83325..934b2655 100644 --- a/unit_test/architecture_test.py +++ b/unit_test/architecture_test.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import platform as platform_module import shutil import sys diff --git a/unit_test/build_ids_test.py b/unit_test/build_ids_test.py index d389fcf8..13014c24 100644 --- a/unit_test/build_ids_test.py +++ b/unit_test/build_ids_test.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import tomllib from packaging.version import Version diff --git a/unit_test/build_selector_test.py b/unit_test/build_selector_test.py index 33fa936f..992677ed 100644 --- a/unit_test/build_selector_test.py +++ b/unit_test/build_selector_test.py @@ -1,5 +1,3 @@ -from __future__ import annotations - from packaging.specifiers import SpecifierSet from cibuildwheel.selector import BuildSelector, EnableGroup diff --git a/unit_test/conftest.py b/unit_test/conftest.py index c67b2408..a51f10d8 100644 --- a/unit_test/conftest.py +++ b/unit_test/conftest.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import sys from pathlib import Path diff --git a/unit_test/dependency_constraints_test.py b/unit_test/dependency_constraints_test.py index 2263d4f3..5fcdd600 100644 --- a/unit_test/dependency_constraints_test.py +++ b/unit_test/dependency_constraints_test.py @@ -1,5 +1,3 @@ -from __future__ import annotations - from pathlib import Path from cibuildwheel.util.packaging import DependencyConstraints diff --git a/unit_test/download_test.py b/unit_test/download_test.py index 41c264d0..ca54e9dc 100644 --- a/unit_test/download_test.py +++ b/unit_test/download_test.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import ssl import certifi diff --git a/unit_test/environment_test.py b/unit_test/environment_test.py index f4229f80..c5e6e57c 100644 --- a/unit_test/environment_test.py +++ b/unit_test/environment_test.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import os import sys diff --git a/unit_test/linux_build_steps_test.py b/unit_test/linux_build_steps_test.py index df187d4f..b493496e 100644 --- a/unit_test/linux_build_steps_test.py +++ b/unit_test/linux_build_steps_test.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import textwrap from pathlib import Path from pprint import pprint diff --git a/unit_test/main_tests/conftest.py b/unit_test/main_tests/conftest.py index e93a4b74..3751b78a 100644 --- a/unit_test/main_tests/conftest.py +++ b/unit_test/main_tests/conftest.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import contextlib import platform as platform_module import subprocess diff --git a/unit_test/main_tests/main_options_test.py b/unit_test/main_tests/main_options_test.py index 2cec4b0e..c020a7ce 100644 --- a/unit_test/main_tests/main_options_test.py +++ b/unit_test/main_tests/main_options_test.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import sys import tomllib from fnmatch import fnmatch diff --git a/unit_test/main_tests/main_platform_test.py b/unit_test/main_tests/main_platform_test.py index cd9add85..63f80eca 100644 --- a/unit_test/main_tests/main_platform_test.py +++ b/unit_test/main_tests/main_platform_test.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import sys import pytest diff --git a/unit_test/main_tests/main_requires_python_test.py b/unit_test/main_tests/main_requires_python_test.py index 75820c45..2fff5275 100644 --- a/unit_test/main_tests/main_requires_python_test.py +++ b/unit_test/main_tests/main_requires_python_test.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import sys import textwrap diff --git a/unit_test/oci_container_test.py b/unit_test/oci_container_test.py index 95bb2412..14c635b3 100644 --- a/unit_test/oci_container_test.py +++ b/unit_test/oci_container_test.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import json import os import platform diff --git a/unit_test/option_prepare_test.py b/unit_test/option_prepare_test.py index db0bc206..995048b2 100644 --- a/unit_test/option_prepare_test.py +++ b/unit_test/option_prepare_test.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import platform as platform_module import subprocess import sys diff --git a/unit_test/options_test.py b/unit_test/options_test.py index 603e0794..fe6f9c34 100644 --- a/unit_test/options_test.py +++ b/unit_test/options_test.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import os import platform as platform_module import textwrap diff --git a/unit_test/options_toml_test.py b/unit_test/options_toml_test.py index 2045ab16..749ff4b5 100644 --- a/unit_test/options_toml_test.py +++ b/unit_test/options_toml_test.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import shlex from pathlib import Path diff --git a/unit_test/projectfiles_test.py b/unit_test/projectfiles_test.py index 05975b22..3bb659f7 100644 --- a/unit_test/projectfiles_test.py +++ b/unit_test/projectfiles_test.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import tomllib from textwrap import dedent diff --git a/unit_test/utils_test.py b/unit_test/utils_test.py index b1ae1305..3c4a5885 100644 --- a/unit_test/utils_test.py +++ b/unit_test/utils_test.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import textwrap from pathlib import PurePath from unittest.mock import Mock, call diff --git a/unit_test/validate_schema_test.py b/unit_test/validate_schema_test.py index f322102b..1670d18c 100644 --- a/unit_test/validate_schema_test.py +++ b/unit_test/validate_schema_test.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import re import tomllib from pathlib import Path diff --git a/unit_test/wheel_print_test.py b/unit_test/wheel_print_test.py index fc97cbec..c3e4933a 100644 --- a/unit_test/wheel_print_test.py +++ b/unit_test/wheel_print_test.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import pytest from cibuildwheel.__main__ import print_new_wheels