From 1efccd03b53187756dbd24cc8f56e9e8290bd5ac Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 26 Oct 2023 10:57:23 -0400 Subject: [PATCH] fix: minor ruff updates (#1649) Signed-off-by: Henry Schreiner --- .pre-commit-config.yaml | 4 ++-- bin/run_example_ci_configs.py | 9 +++++++-- cibuildwheel/_compat/typing.py | 5 +++-- cibuildwheel/oci_container.py | 3 ++- pyproject.toml | 17 ++++++++++------- 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index baa6f089c..1cf49e178 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,12 +14,12 @@ repos: - id: trailing-whitespace - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.10.0 + rev: 23.10.1 hooks: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.1 + rev: v0.1.2 hooks: - id: ruff args: ["--fix", "--show-fixes"] diff --git a/bin/run_example_ci_configs.py b/bin/run_example_ci_configs.py index ef3c6eaad..5c5dfbe34 100755 --- a/bin/run_example_ci_configs.py +++ b/bin/run_example_ci_configs.py @@ -7,7 +7,7 @@ import sys import textwrap import time -from collections import namedtuple +import typing from glob import glob from pathlib import Path from subprocess import run @@ -34,7 +34,12 @@ def generate_basic_project(path): project.generate(path) -CIService = namedtuple("CIService", "name dst_config_path badge_md") +class CIService(typing.NamedTuple): + name: str + dst_config_path: str + badge_md: str + + services = [ CIService( name="appveyor", diff --git a/cibuildwheel/_compat/typing.py b/cibuildwheel/_compat/typing.py index d1aa72271..05bae73e0 100644 --- a/cibuildwheel/_compat/typing.py +++ b/cibuildwheel/_compat/typing.py @@ -3,11 +3,12 @@ import sys if sys.version_info < (3, 11): - from typing_extensions import NotRequired, assert_never + from typing_extensions import NotRequired, Self, assert_never else: - from typing import NotRequired, assert_never + from typing import NotRequired, Self, assert_never __all__ = ( "assert_never", "NotRequired", + "Self", ) diff --git a/cibuildwheel/oci_container.py b/cibuildwheel/oci_container.py index 1b2e207bf..3111ff953 100644 --- a/cibuildwheel/oci_container.py +++ b/cibuildwheel/oci_container.py @@ -16,6 +16,7 @@ from types import TracebackType from typing import IO, Dict, Literal +from ._compat.typing import Self from .typing import PathOrStr, PopenBytes from .util import ( CIProvider, @@ -105,7 +106,7 @@ def __init__( self.name: str | None = None self.engine = engine - def __enter__(self) -> OCIContainer: + def __enter__(self) -> Self: self.name = f"cibuildwheel-{uuid.uuid4()}" # work-around for Travis-CI PPC64le Docker runs since 2021: diff --git a/pyproject.toml b/pyproject.toml index bf84836e4..8cb17c860 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -115,8 +115,10 @@ messages_control.disable = [ ] [tool.ruff] -select = [ - "E", "F", "W", # flake8 +target-version = "py38" + +[tool.ruff.lint] +extend-select = [ "B", # flake8-bugbear "I", # isort "ARG", # flake8-unused-arguments @@ -136,19 +138,20 @@ select = [ "UP", # pyupgrade "YTT", # flake8-2020 "EXE", # flake8-executable + "PYI", # flake8-pyi ] -extend-ignore = [ +ignore = [ "PLR", # Design related pylint codes "E501", # Line too long "RET504", "RET505", "RET508", # else after control flow "PT004", # Rename suggested for returnless fixtures - "PT007", # False positive (fixed upstream) + "PT007", # False positive + "PYI025", # Set as AbstractSet ] -target-version = "py38" typing-modules = ["cibuildwheel._compat.typing"] flake8-unused-arguments.ignore-variadic-names = true -[tool.ruff.flake8-tidy-imports.banned-api] +[tool.ruff.lint.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." @@ -159,6 +162,6 @@ flake8-unused-arguments.ignore-variadic-names = true "tomllib".msg = "Use cibuildwheel._compat.tomllib instead." "tomli".msg = "Use cibuildwheel._compat.tomllib instead." -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "unit_test/*" = ["PLC1901"] "cibuildwheel/_compat/**.py" = ["TID251"]