From 2f1014aa60e5714fc754ea615e9cb0e4da7ef787 Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Thu, 5 Sep 2024 08:58:23 +0200 Subject: [PATCH] Black dropped us 5 years ago https://github.com/psf/black/commit/31f4105731c9e5a6930905d358b62b2b834b940b --- .github/CONTRIBUTING.md | 2 +- .pre-commit-config.yaml | 6 +----- pyproject.toml | 10 ++++------ src/attr/_next_gen.py | 1 - src/attr/converters.py | 1 - src/attr/validators.py | 1 - src/attr/validators.pyi | 4 ++-- tests/strategies.py | 1 + tests/test_config.py | 1 - tests/test_dunders.py | 5 ++--- tests/test_filters.py | 1 - tests/test_make.py | 1 + tests/test_pattern_matching.py | 1 - tests/test_validators.py | 1 - tests/utils.py | 1 - 15 files changed, 12 insertions(+), 25 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index cf1f8d77d..0a882d390 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -109,7 +109,7 @@ You will find the built documentation in `docs/_build/html`. ## Code -- We follow [PEP 8](https://peps.python.org/pep-0008/) as enforced by [Ruff](https://ruff.rs/) and [Black](https://github.com/psf/black) with a line length of 79 characters. +- We follow [PEP 8](https://peps.python.org/pep-0008/) as enforced by [Ruff](https://ruff.rs/) with a line length of 79 characters. - As long as you run our full *tox* suite before committing, or install our [*pre-commit*](https://pre-commit.com/) hooks, you won't have to spend any time on formatting your code at all. If you don't, CI will catch it for you -- but that seems like a waste of your time! diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 362f4d0f9..1a450c18c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,14 +3,10 @@ ci: autoupdate_schedule: monthly repos: - - repo: https://github.com/psf/black - rev: 24.8.0 - hooks: - - id: black - - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.6.3 hooks: + - id: ruff-format - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/pyproject.toml b/pyproject.toml index d9beb0c5a..055686366 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -173,10 +173,6 @@ exclude_lines = [ ] -[tool.black] -line-length = 79 - - [tool.interrogate] omit-covered-files = true verbose = 2 @@ -190,6 +186,7 @@ toplevel = ["attr", "attrs"] [tool.ruff] src = ["src", "tests", "conftest.py", "docs"] +line-length = 79 [tool.ruff.lint] select = ["ALL"] @@ -200,12 +197,13 @@ ignore = [ "ANN", # Mypy is better at this "ARG", # unused arguments are normal when implementing interfaces "C901", # we're complex software - "COM", # Black takes care of our commas + "COM", # ruff format takes care of our commas "D", # We prefer our own docstring style. - "E501", # leave line-length enforcement to Black + "E501", # leave line-length enforcement to ruff format "ERA001", # we need to keep around some notes "FBT", # we don't hate bool args around here "FIX", # Yes, we want XXX as a marker. + "ISC001", # conflicts with ruff format "N", # we need more naming freedom "PD", # we're not pandas "PLR0912", # we're complex software diff --git a/src/attr/_next_gen.py b/src/attr/_next_gen.py index dbb65cc97..169799a83 100644 --- a/src/attr/_next_gen.py +++ b/src/attr/_next_gen.py @@ -5,7 +5,6 @@ default values. """ - from functools import partial from . import setters diff --git a/src/attr/converters.py b/src/attr/converters.py index 92383110a..cac62dda7 100644 --- a/src/attr/converters.py +++ b/src/attr/converters.py @@ -4,7 +4,6 @@ Commonly useful converters. """ - import typing from ._compat import _AnnotationExtractor diff --git a/src/attr/validators.py b/src/attr/validators.py index 8a56717df..efa08aa55 100644 --- a/src/attr/validators.py +++ b/src/attr/validators.py @@ -4,7 +4,6 @@ Commonly useful validators. """ - import operator import re diff --git a/src/attr/validators.pyi b/src/attr/validators.pyi index a314110e6..a04d43e14 100644 --- a/src/attr/validators.pyi +++ b/src/attr/validators.pyi @@ -36,11 +36,11 @@ def instance_of(type: type[_T]) -> _ValidatorType[_T]: ... def instance_of(type: tuple[type[_T]]) -> _ValidatorType[_T]: ... @overload def instance_of( - type: tuple[type[_T1], type[_T2]] + type: tuple[type[_T1], type[_T2]], ) -> _ValidatorType[_T1 | _T2]: ... @overload def instance_of( - type: tuple[type[_T1], type[_T2], type[_T3]] + type: tuple[type[_T1], type[_T2], type[_T3]], ) -> _ValidatorType[_T1 | _T2 | _T3]: ... @overload def instance_of(type: tuple[type, ...]) -> _ValidatorType[Any]: ... diff --git a/tests/strategies.py b/tests/strategies.py index c01f666f8..c745e3f61 100644 --- a/tests/strategies.py +++ b/tests/strategies.py @@ -3,6 +3,7 @@ """ Testing strategies for Hypothesis-based tests. """ + import functools import keyword import string diff --git a/tests/test_config.py b/tests/test_config.py index 6c78fd295..9b62e9d9c 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -4,7 +4,6 @@ Tests for `attr._config`. """ - import pytest from attr import _config diff --git a/tests/test_dunders.py b/tests/test_dunders.py index 5b26f2bbe..cfd51c84c 100644 --- a/tests/test_dunders.py +++ b/tests/test_dunders.py @@ -4,7 +4,6 @@ Tests for dunder methods from `attrib._make`. """ - import copy import inspect import pickle @@ -481,12 +480,12 @@ def test_enforces_type(self): exc_args = ("Invalid value for hash. Must be True, False, or None.",) with pytest.raises(TypeError) as e: - make_class("C", {}, unsafe_hash=1), + make_class("C", {}, unsafe_hash=1) assert exc_args == e.value.args with pytest.raises(TypeError) as e: - make_class("C", {"a": attr.ib(hash=1)}), + make_class("C", {"a": attr.ib(hash=1)}) assert exc_args == e.value.args diff --git a/tests/test_filters.py b/tests/test_filters.py index 6d237fdc3..08314fa88 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -4,7 +4,6 @@ Tests for `attr.filters`. """ - import pytest import attr diff --git a/tests/test_make.py b/tests/test_make.py index a7b871069..cc78cb3a4 100644 --- a/tests/test_make.py +++ b/tests/test_make.py @@ -3,6 +3,7 @@ """ Tests for `attr._make`. """ + import copy import functools import gc diff --git a/tests/test_pattern_matching.py b/tests/test_pattern_matching.py index 3855d6a37..fc8546b3b 100644 --- a/tests/test_pattern_matching.py +++ b/tests/test_pattern_matching.py @@ -1,6 +1,5 @@ # SPDX-License-Identifier: MIT -# Keep this file SHORT, until Black can handle it. import pytest import attr diff --git a/tests/test_validators.py b/tests/test_validators.py index 9127e57e6..e238a78c1 100644 --- a/tests/test_validators.py +++ b/tests/test_validators.py @@ -4,7 +4,6 @@ Tests for `attr.validators`. """ - import re import pytest diff --git a/tests/utils.py b/tests/utils.py index 3ad484ee7..eefcbd242 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -4,7 +4,6 @@ Common helper functions for tests. """ - from attr import Attribute from attr._make import NOTHING, _default_init_alias_for, make_class