Skip to content

Commit

Permalink
fix: minor ruff updates (#1649)
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
  • Loading branch information
henryiii authored Oct 26, 2023
1 parent c4fdf66 commit 1efccd0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
9 changes: 7 additions & 2 deletions bin/run_example_ci_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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",
Expand Down
5 changes: 3 additions & 2 deletions cibuildwheel/_compat/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
3 changes: 2 additions & 1 deletion cibuildwheel/oci_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
17 changes: 10 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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."
Expand All @@ -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"]

0 comments on commit 1efccd0

Please sign in to comment.