From c245516a9fa79e09bc25ff8684566eed6e225edb Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Wed, 14 Aug 2024 17:46:38 +0100 Subject: [PATCH 1/2] Adopt Ruff --- .flake8 | 2 -- .pre-commit-config.yaml | 38 ++++++++------------------------ .ruff.toml | 34 ++++++++++++++++++++++++++++ _tools/generate_release_cycle.py | 7 ++---- 4 files changed, 45 insertions(+), 36 deletions(-) delete mode 100644 .flake8 create mode 100644 .ruff.toml diff --git a/.flake8 b/.flake8 deleted file mode 100644 index f4546adb4..000000000 --- a/.flake8 +++ /dev/null @@ -1,2 +0,0 @@ -[flake8] -max_line_length = 88 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 60ea4bc4b..3ec54847a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,33 +1,13 @@ repos: - - repo: https://github.com/asottile/pyupgrade - rev: v3.15.0 - hooks: - - id: pyupgrade - args: [--py38-plus] - - - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.12.1 - hooks: - - id: black - args: [--skip-string-normalization] - - - repo: https://github.com/PyCQA/isort - rev: 5.13.2 - hooks: - - id: isort - args: [--profile=black] - - - repo: https://github.com/PyCQA/flake8 - rev: 6.1.0 - hooks: - - id: flake8 - additional_dependencies: - [flake8-2020, flake8-implicit-str-concat] - - - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.10.0 - hooks: - - id: python-check-blanket-noqa + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.5.7 + hooks: + - id: ruff-format + name: Run Ruff (format) + args: [--check] + - id: ruff + name: Run Ruff (lint) + args: [--exit-non-zero-on-fix] - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 000000000..00d9b77df --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,34 @@ +target-version = "py312" +fix = true +output-format = "full" +line-length = 88 + +[lint] +preview = true +select = [ + "C4", # flake8-comprehensions + "B", # flake8-bugbear + "E", # pycodestyle + "F", # pyflakes + "FA", # flake8-future-annotations + "FLY", # flynt + "FURB", # refurb + "G", # flake8-logging-format + "I", # isort + "ISC", # flake8-implicit-str-concat + "LOG", # flake8-logging + "PERF", # perflint + "PGH", # pygrep-hooks + "PT", # flake8-pytest-style + "TCH", # flake8-type-checking + "UP", # pyupgrade + "W", # pycodestyle +] +ignore = [ + "E501", # Ignore line length errors (we use auto-formatting) +] + +[format] +preview = true +quote-style = "preserve" +docstring-code-format = true diff --git a/_tools/generate_release_cycle.py b/_tools/generate_release_cycle.py index 27b5cc3ec..ed27424dd 100644 --- a/_tools/generate_release_cycle.py +++ b/_tools/generate_release_cycle.py @@ -1,11 +1,11 @@ """Read in a JSON and generate two CSVs and an SVG file.""" + from __future__ import annotations import argparse import csv import datetime as dt import json -import sys import jinja2 @@ -45,10 +45,7 @@ def __init__(self) -> None: def write_csv(self) -> None: """Output CSV files.""" - if sys.version_info >= (3, 11): - now_str = str(dt.datetime.now(dt.UTC)) - else: - now_str = str(dt.datetime.utcnow()) + now_str = str(dt.datetime.now(dt.UTC)) versions_by_category = {"branches": {}, "end-of-life": {}} headers = None From 3332026166edac720461a32a8a99bc42a0f0e5c2 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Wed, 14 Aug 2024 19:12:55 +0100 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- .pre-commit-config.yaml | 6 +++--- .ruff.toml | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3ec54847a..ae27fd1f2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,12 +2,12 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.5.7 hooks: - - id: ruff-format - name: Run Ruff (format) - args: [--check] - id: ruff name: Run Ruff (lint) args: [--exit-non-zero-on-fix] + - id: ruff-format + name: Run Ruff (format) + args: [--check] - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 diff --git a/.ruff.toml b/.ruff.toml index 00d9b77df..550f27e61 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -1,4 +1,4 @@ -target-version = "py312" +target-version = "py311" fix = true output-format = "full" line-length = 88 @@ -23,6 +23,7 @@ select = [ "TCH", # flake8-type-checking "UP", # pyupgrade "W", # pycodestyle + "YTT", # flake8-2020 ] ignore = [ "E501", # Ignore line length errors (we use auto-formatting)