Skip to content

Commit 4328637

Browse files
committed
Adopt Ruff
1 parent c75cafb commit 4328637

File tree

44 files changed

+162
-20
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+162
-20
lines changed

.github/workflows/lint.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Lint source code
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
13+
cancel-in-progress: true
14+
15+
env:
16+
FORCE_COLOR: "1"
17+
UV_SYSTEM_PYTHON: "1" # make uv do global installs
18+
19+
jobs:
20+
ruff:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
persist-credentials: false
27+
28+
- name: Install Ruff
29+
uses: astral-sh/ruff-action@v3
30+
with:
31+
args: --version
32+
version: 0.9.2
33+
34+
- name: Lint with Ruff
35+
run: ruff check --output-format=github
36+
37+
- name: Format with Ruff
38+
run: ruff format --diff

.github/workflows/workflow.yml

-19
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,6 @@ env:
77
FORCE_COLOR: "1"
88

99
jobs:
10-
check:
11-
runs-on: ubuntu-latest
12-
13-
# We want to run on external PRs, but not on our own internal PRs as they'll be run
14-
# by the push to the branch.
15-
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
16-
17-
steps:
18-
- uses: actions/checkout@v4
19-
- uses: actions/setup-python@v5
20-
with:
21-
python-version: "3"
22-
cache: pip
23-
cache-dependency-path: .github/workflows/workflow.yml
24-
- name: Black
25-
run: |
26-
pip install black
27-
black --check --exclude /docs --diff .
28-
2910
build-wheel:
3011
runs-on: ubuntu-latest
3112
steps:

.ruff.toml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
target-version = "py39" # Pin Ruff to Python 3.9
2+
line-length = 88
3+
output-format = "full"
4+
5+
[format]
6+
quote-style = "double"
7+
docstring-code-format = true
8+
9+
[lint]
10+
select = [
11+
# "C4", # flake8-comprehensions
12+
# "B", # flake8-bugbear
13+
"E", # pycodestyle
14+
# "F", # pyflakes
15+
"FA", # flake8-future-annotations
16+
"FLY", # flynt
17+
"FURB", # refurb
18+
# "G", # flake8-logging-format
19+
"I", # isort
20+
"LOG", # flake8-logging
21+
"PERF", # perflint
22+
# "PGH", # pygrep-hooks
23+
# "PT", # flake8-pytest-style
24+
# "TC", # flake8-type-checking
25+
# "UP", # pyupgrade
26+
"W", # pycodestyle
27+
]
28+
ignore = [
29+
"E501", # Ignore line length errors (we use auto-formatting)
30+
]
31+
32+
[lint.flake8-type-checking]
33+
exempt-modules = []
34+
strict = true
35+
36+
[lint.isort]
37+
forced-separate = [
38+
"tests",
39+
]
40+
required-imports = [
41+
"from __future__ import annotations",
42+
]

README.md

+1-1

docs/script/generate_social_card_previews.py

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
# %load_ext autoreload
77
# %autoreload 2
88

9+
from __future__ import annotations
10+
911
import random
1012
from pathlib import Path
1113
from textwrap import dedent

docs/source/conf.py

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
# add these directories to sys.path here. If the directory is relative to the
1111
# documentation root, use os.path.abspath to make it absolute, like shown here.
1212
#
13+
14+
from __future__ import annotations
15+
1316
import os
1417
import sys
1518
from subprocess import run

noxfile.py

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
ref: https://nox.thea.codes/
1212
"""
1313

14+
from __future__ import annotations
15+
1416
from shlex import split
1517

1618
import nox

sphinxext/opengraph/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import os
24
from pathlib import Path
35
from typing import Any, Dict

sphinxext/opengraph/descriptionparser.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import string
24
from collections.abc import Set
35

sphinxext/opengraph/metaparser.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from html.parser import HTMLParser
24

35

sphinxext/opengraph/socialcards.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Build a PNG card for each page meant for social media."""
22

3+
from __future__ import annotations
4+
35
import hashlib
46
from pathlib import Path
57

sphinxext/opengraph/titleparser.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from html.parser import HTMLParser
24

35

tests/conftest.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from pathlib import Path
24

35
import pytest

tests/roots/test-arbitrary-tags/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-custom-tags/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-description-length/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-double-spacing/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-first-image-no-image/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-first-image/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-image-rel-paths/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-image/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-list/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-local-image/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-meta-name-description-manual-description/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-meta-name-description-manual-og-description/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-meta-name-description/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-nested-lists/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-overrides-complex/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-overrides-disable/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-overrides-simple/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-quotation-marks/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-rtd-default/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-rtd-invalid/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-simple/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-sitename-from-project/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
project = "Project name"

tests/roots/test-sitename/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-skip-admonitions/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-skip-code-block/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-skip-comments/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-skip-raw/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-skip-title/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-social-cards-svg/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/roots/test-type/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
extensions = ["sphinxext.opengraph"]
24

35
master_doc = "index"

tests/test_options.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import conftest
24
import pytest
35
from sphinx.application import Sphinx

0 commit comments

Comments
 (0)