chore: move to ruff-format (#1651)

* chore: move to ruff-format

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* Apply suggestions from code review

* Apply suggestions from code review

* chore: bump Ruff

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

---------

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
This commit is contained in:
Henry Schreiner
2023-10-27 01:21:20 -04:00
committed by GitHub
parent 1efccd03b5
commit 4586062efb
13 changed files with 21 additions and 58 deletions
+2 -6
View File
@@ -13,16 +13,12 @@ repos:
- id: mixed-line-ending - id: mixed-line-ending
- id: trailing-whitespace - id: trailing-whitespace
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.10.1
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit - repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.2 rev: v0.1.3
hooks: hooks:
- id: ruff - id: ruff
args: ["--fix", "--show-fixes"] args: ["--fix", "--show-fixes"]
- id: ruff-format
- repo: https://github.com/asottile/setup-cfg-fmt - repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.5.0 rev: v2.5.0
+2 -4
View File
@@ -204,10 +204,8 @@ class CPythonVersions:
unsorted_versions = spec.filter(self.versions_dict) unsorted_versions = spec.filter(self.versions_dict)
sorted_versions = sorted(unsorted_versions, reverse=True) sorted_versions = sorted(unsorted_versions, reverse=True)
if version <= Version("3.8.9999"): macver = "x10.9" if version <= Version("3.8.9999") else "11"
file_ident = "macosx10.9.pkg" file_ident = f"macos{macver}.pkg"
else:
file_ident = "macos11.pkg"
for new_version in sorted_versions: for new_version in sorted_versions:
# Find the first patch version that contains the requested file # Find the first patch version that contains the requested file
+1 -4
View File
@@ -619,10 +619,7 @@ def virtualenv(
python, python,
venv_path, venv_path,
) )
if IS_WIN: paths = [str(venv_path), str(venv_path / "Scripts")] if IS_WIN else [str(venv_path / "bin")]
paths = [str(venv_path), str(venv_path / "Scripts")]
else:
paths = [str(venv_path / "bin")]
env = os.environ.copy() env = os.environ.copy()
env["PATH"] = os.pathsep.join([*paths, env["PATH"]]) env["PATH"] = os.pathsep.join([*paths, env["PATH"]])
return env return env
+3 -5
View File
@@ -5,11 +5,6 @@ requires = [
build-backend = "setuptools.build_meta" build-backend = "setuptools.build_meta"
[tool.black]
line-length = 100
target-version = ['py38', 'py39', 'py310', 'py311']
[tool.pytest.ini_options] [tool.pytest.ini_options]
minversion = "6.0" minversion = "6.0"
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"] addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
@@ -116,6 +111,8 @@ messages_control.disable = [
[tool.ruff] [tool.ruff]
target-version = "py38" target-version = "py38"
line-length = 100
[tool.ruff.lint] [tool.ruff.lint]
extend-select = [ extend-select = [
@@ -147,6 +144,7 @@ ignore = [
"PT004", # Rename suggested for returnless fixtures "PT004", # Rename suggested for returnless fixtures
"PT007", # False positive "PT007", # False positive
"PYI025", # Set as AbstractSet "PYI025", # Set as AbstractSet
"ISC001", # Conflicts with formatter
] ]
typing-modules = ["cibuildwheel._compat.typing"] typing-modules = ["cibuildwheel._compat.typing"]
flake8-unused-arguments.ignore-variadic-names = true flake8-unused-arguments.ignore-variadic-names = true
+1 -3
View File
@@ -3,9 +3,7 @@ from __future__ import annotations
from . import test_projects, utils from . import test_projects, utils
before_test_project = test_projects.new_c_project() before_test_project = test_projects.new_c_project()
before_test_project.files[ before_test_project.files["test/spam_test.py"] = r"""
"test/spam_test.py"
] = r"""
import sys import sys
import os import os
from unittest import TestCase from unittest import TestCase
+1 -3
View File
@@ -99,9 +99,7 @@ cpp17_project = cpp_test_project.copy()
cpp17_project.template_context["extra_compile_args"] = [ cpp17_project.template_context["extra_compile_args"] = [
"/std:c++17" if utils.platform == "windows" else "-std=c++17" "/std:c++17" if utils.platform == "windows" else "-std=c++17"
] ]
cpp17_project.template_context[ cpp17_project.template_context["spam_cpp_top_level_add"] = r"""
"spam_cpp_top_level_add"
] = r"""
#include <utility> #include <utility>
auto a = std::pair(5.0, false); auto a = std::pair(5.0, false);
""" """
+1 -3
View File
@@ -135,9 +135,7 @@ def test_dependency_constraints_file(tmp_path, build_frontend_env):
wheel=={wheel} wheel=={wheel}
virtualenv=={virtualenv} virtualenv=={virtualenv}
importlib-metadata<3,>=0.12; python_version < "3.8" importlib-metadata<3,>=0.12; python_version < "3.8"
""".format( """.format(**tool_versions)
**tool_versions
)
) )
) )
+1 -3
View File
@@ -8,9 +8,7 @@ from . import test_projects, utils
project_with_a_test = test_projects.new_c_project() project_with_a_test = test_projects.new_c_project()
project_with_a_test.files[ project_with_a_test.files["test/spam_test.py"] = r"""
"test/spam_test.py"
] = r"""
import spam import spam
def test_spam(): def test_spam():
+1 -3
View File
@@ -19,9 +19,7 @@ basic_project = test_projects.new_c_project(
) )
) )
basic_project.files[ basic_project.files["pyproject.toml"] = """
"pyproject.toml"
] = """
[build-system] [build-system]
requires = [ requires = [
"setuptools >= 42", "setuptools >= 42",
+2 -6
View File
@@ -8,9 +8,7 @@ import pytest
from . import utils from . import utils
pure_python_project = test_projects.TestProject() pure_python_project = test_projects.TestProject()
pure_python_project.files[ pure_python_project.files["setup.py"] = """
"setup.py"
] = """
from setuptools import Extension, setup from setuptools import Extension, setup
setup( setup(
@@ -20,9 +18,7 @@ setup(
) )
""" """
pure_python_project.files[ pure_python_project.files["spam.py"] = """
"spam.py"
] = """
def a_function(): def a_function():
pass pass
""" """
+1 -3
View File
@@ -8,9 +8,7 @@ import pytest
from . import utils from . import utils
basic_project = test_projects.new_c_project() basic_project = test_projects.new_c_project()
basic_project.files[ basic_project.files["repair.py"] = """
"repair.py"
] = """
import shutil import shutil
import sys import sys
from pathlib import Path from pathlib import Path
+3 -9
View File
@@ -14,9 +14,7 @@ subdir_package_project.files["src/spam/spam.c"] = jinja2.Template(SPAM_C_TEMPLAT
subdir_package_project.template_context["spam_c_top_level_add"] = "" subdir_package_project.template_context["spam_c_top_level_add"] = ""
subdir_package_project.template_context["spam_c_function_add"] = "" subdir_package_project.template_context["spam_c_function_add"] = ""
subdir_package_project.files[ subdir_package_project.files["src/spam/setup.py"] = r"""
"src/spam/setup.py"
] = r"""
from setuptools import Extension, setup from setuptools import Extension, setup
setup( setup(
@@ -26,15 +24,11 @@ setup(
) )
""" """
subdir_package_project.files[ subdir_package_project.files["src/spam/test/run_tests.py"] = r"""
"src/spam/test/run_tests.py"
] = r"""
print('run_tests.py executed!') print('run_tests.py executed!')
""" """
subdir_package_project.files[ subdir_package_project.files["bin/before_build.py"] = r"""
"bin/before_build.py"
] = r"""
print('before_build.py executed!') print('before_build.py executed!')
""" """
+2 -6
View File
@@ -18,9 +18,7 @@ project_with_a_test = test_projects.new_c_project(
) )
) )
project_with_a_test.files[ project_with_a_test.files["test/spam_test.py"] = r'''
"test/spam_test.py"
] = r'''
import os import os
import platform import platform
import sys import sys
@@ -115,9 +113,7 @@ def test_extras_require(tmp_path):
project_with_a_failing_test = test_projects.new_c_project() project_with_a_failing_test = test_projects.new_c_project()
project_with_a_failing_test.files[ project_with_a_failing_test.files["test/spam_test.py"] = r"""
"test/spam_test.py"
] = r"""
from unittest import TestCase from unittest import TestCase
class TestSpam(TestCase): class TestSpam(TestCase):