style: remove from future import annotations

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
This commit is contained in:
Henry Schreiner
2025-02-28 16:38:15 -05:00
committed by Henry Schreiner
parent 1b63074d76
commit 708cf1d32b
93 changed files with 63 additions and 239 deletions
-2
View File
@@ -5,8 +5,6 @@
# ///
from __future__ import annotations
import os
import subprocess
import sys
-2
View File
@@ -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
-1
View File
@@ -1,6 +1,5 @@
#!/usr/bin/env python3
from __future__ import annotations
import os
import subprocess
+2 -4
View File
@@ -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:
-1
View File
@@ -1,6 +1,5 @@
#!/usr/bin/env python3
from __future__ import annotations
import os
import shutil
-1
View File
@@ -1,6 +1,5 @@
#!/usr/bin/env python3
from __future__ import annotations
import argparse
import os
-1
View File
@@ -1,6 +1,5 @@
#!/usr/bin/env python3
from __future__ import annotations
import argparse
import os
-1
View File
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
from __future__ import annotations
import configparser
from dataclasses import dataclass
-1
View File
@@ -1,6 +1,5 @@
#!/usr/bin/env python3
from __future__ import annotations
import subprocess
import sys
-1
View File
@@ -1,6 +1,5 @@
#!/usr/bin/env python3
from __future__ import annotations
import difflib
import logging
-1
View File
@@ -1,6 +1,5 @@
#!/usr/bin/env python3
from __future__ import annotations
import copy
import difflib
-1
View File
@@ -1,6 +1,5 @@
#!/usr/bin/env python3
from __future__ import annotations
import re
import sys
-1
View File
@@ -1,6 +1,5 @@
#!/usr/bin/env python3
from __future__ import annotations
import difflib
import logging
-2
View File
@@ -1,3 +1 @@
from __future__ import annotations
__version__ = "2.22.0"
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import argparse
import contextlib
import dataclasses
+9 -9
View File
@@ -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(
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import subprocess
from collections.abc import (
Callable,
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import os
import re
from enum import Enum
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import dataclasses
from collections.abc import Mapping, Sequence
from typing import Any, Protocol
-2
View File
@@ -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
+4 -6
View File
@@ -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:
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import contextlib
import subprocess
import sys
+26 -28
View File
@@ -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.
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import functools
import inspect
import os
+3 -7
View File
@@ -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:
+12 -14
View File
@@ -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={},
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import ast
import configparser
import contextlib
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import functools
import os
import shutil
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import json
from typing import Any
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import fnmatch
import itertools
from dataclasses import dataclass
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import os
import typing
from typing import Final, Literal, Protocol
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import os
import shlex
import shutil
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import os
import shutil
import ssl
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import itertools
import os
import re
+4 -6
View File
@@ -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"
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import tomllib
from pathlib import Path
from typing import Final
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import contextlib
import functools
import os
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import os
import platform as platform_module
import shutil
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import os
import subprocess
import sysconfig
-2
View File
@@ -15,8 +15,6 @@ Tags:
See sessions with `nox -l`
"""
from __future__ import annotations
import os
import shutil
import sys
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import json
import subprocess
from collections.abc import Generator
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import textwrap
import pytest
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import textwrap
from . import test_projects, utils
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import subprocess
import textwrap
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import subprocess
import textwrap
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
from . import test_projects, utils
before_test_project = test_projects.new_c_project()
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import textwrap
from . import test_projects, utils
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import pytest
from . import test_projects, utils
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import platform
import textwrap
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import os
import jinja2
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import subprocess
from contextlib import nullcontext as does_not_raise
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import re
import textwrap
from pathlib import Path
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import shutil
import sys
import textwrap
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import itertools
import subprocess
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import os
import subprocess
import sys
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import os
import subprocess
import sys
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import platform
import subprocess
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import platform
import subprocess
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import platform
import textwrap
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import textwrap
import pytest
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import textwrap
from . import test_projects, utils
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
from .base import TestProject
from .c import new_c_project
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import importlib
import subprocess
import sys
+3 -5
View File
@@ -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
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import jinja2
from .base import TestProject
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import subprocess
import pytest
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import textwrap
from . import test_projects, utils
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
from pathlib import Path
import jinja2
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import inspect
import os
import subprocess
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import subprocess
import pytest
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import pytest
from . import test_projects, utils
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import os
import subprocess
import textwrap
-2
View File
@@ -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
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import platform as platform_module
import shutil
import sys
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import tomllib
from packaging.version import Version
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
from packaging.specifiers import SpecifierSet
from cibuildwheel.selector import BuildSelector, EnableGroup
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import sys
from pathlib import Path
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
from pathlib import Path
from cibuildwheel.util.packaging import DependencyConstraints
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import ssl
import certifi
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import os
import sys
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import textwrap
from pathlib import Path
from pprint import pprint
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import contextlib
import platform as platform_module
import subprocess
@@ -1,5 +1,3 @@
from __future__ import annotations
import sys
import tomllib
from fnmatch import fnmatch
@@ -1,5 +1,3 @@
from __future__ import annotations
import sys
import pytest
@@ -1,5 +1,3 @@
from __future__ import annotations
import sys
import textwrap
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import json
import os
import platform
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import platform as platform_module
import subprocess
import sys
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import os
import platform as platform_module
import textwrap
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import shlex
from pathlib import Path
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import tomllib
from textwrap import dedent
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import textwrap
from pathlib import PurePath
from unittest.mock import Mock, call
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import re
import tomllib
from pathlib import Path
-2
View File
@@ -1,5 +1,3 @@
from __future__ import annotations
import pytest
from cibuildwheel.__main__ import print_new_wheels