Skip to content

Commit e57a3b7

Browse files
committed
refactor: add ruff linting
1 parent 6c73ef4 commit e57a3b7

File tree

23 files changed

+1304
-1400
lines changed

23 files changed

+1304
-1400
lines changed

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ jobs:
1818
python-version: ["3.10"]
1919

2020
steps:
21-
- uses: actions/checkout@v4
21+
- uses: actions/checkout@v5
2222
- name: Set up Python ${{ matrix.python-version }}
23-
uses: actions/setup-python@v4
23+
uses: actions/setup-python@v5
2424
with:
2525
python-version: ${{ matrix.python-version }}
2626
- name: Install dependencies

.github/workflows/test.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ concurrency:
1313
cancel-in-progress: true
1414

1515
jobs:
16+
lint-python:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v5
20+
with:
21+
ref: ${{ github.ref }}
22+
- uses: astral-sh/ruff-action@v3
23+
with:
24+
version: "0.14.x"
25+
- run: ruff check --fix
26+
- run: ruff format --check --diff
1627
test-sqlite:
1728
name: SQlite, Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }}
1829
runs-on: ubuntu-latest
@@ -25,7 +36,7 @@ jobs:
2536
- django-version: 42
2637
python-version: 3.13
2738
steps:
28-
- uses: actions/checkout@v2
39+
- uses: actions/checkout@v5
2940
- name: Set up Python ${{ matrix.python-version }}
3041
uses: actions/setup-python@v5
3142
with:
@@ -57,7 +68,7 @@ jobs:
5768
POSTGRES_PASSWORD: treebeard
5869
POSTGRES_DB: treebeard
5970
steps:
60-
- uses: actions/checkout@v2
71+
- uses: actions/checkout@v5
6172
- name: Set up Python ${{ matrix.python-version }}
6273
uses: actions/setup-python@v5
6374
with:
@@ -92,7 +103,7 @@ jobs:
92103
ports:
93104
- 3306/tcp
94105
steps:
95-
- uses: actions/checkout@v2
106+
- uses: actions/checkout@v5
96107
- name: Set up Python ${{ matrix.python-version }}
97108
uses: actions/setup-python@v5
98109
with:
@@ -127,7 +138,7 @@ jobs:
127138
ports:
128139
- 1433/tcp
129140
steps:
130-
- uses: actions/checkout@v2
141+
- uses: actions/checkout@v5
131142
- name: Set up Python ${{ matrix.python-version }}
132143
uses: actions/setup-python@v5
133144
with:

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
# Ruff version.
4+
rev: v0.14.0
5+
hooks:
6+
# Run the linter.
7+
- id: ruff-check
8+
args: [ --fix ]
9+
# Run the formatter.
10+
- id: ruff-format

docs/source/conf.py

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# django-treebeard documentation build configuration file, created by
43
# sphinx-quickstart on Tue Nov 22 00:05:34 2016.
@@ -14,16 +13,17 @@
1413

1514
import os
1615
import sys
16+
1717
import django
1818
from django.conf import settings
1919

2020
# If extensions (or modules to document with autodoc) are in another directory,
2121
# add these directories to sys.path here. If the directory is relative to the
2222
# documentation root, use os.path.abspath to make it absolute, like shown here.
23-
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '_ext')))
23+
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "_ext")))
2424

2525
settings.configure(
26-
INSTALLED_APPS=['treebeard'],
26+
INSTALLED_APPS=["treebeard"],
2727
)
2828
django.setup()
2929

@@ -36,42 +36,42 @@
3636
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3737
# ones.
3838
extensions = [
39-
'djangodocs',
40-
'sphinx.ext.autodoc',
41-
'sphinx.ext.coverage',
42-
'sphinx.ext.graphviz',
43-
'sphinx.ext.inheritance_diagram',
44-
'sphinx.ext.todo',
45-
'sphinx.ext.intersphinx',
39+
"djangodocs",
40+
"sphinx.ext.autodoc",
41+
"sphinx.ext.coverage",
42+
"sphinx.ext.graphviz",
43+
"sphinx.ext.inheritance_diagram",
44+
"sphinx.ext.todo",
45+
"sphinx.ext.intersphinx",
4646
]
4747

4848
# Add any paths that contain templates here, relative to this directory.
49-
templates_path = ['_templates']
49+
templates_path = ["_templates"]
5050

5151
# The suffix(es) of source filenames.
5252
# You can specify multiple suffix as a list of string:
5353
# source_suffix = ['.rst', '.md']
54-
source_suffix = '.rst'
54+
source_suffix = ".rst"
5555

5656
# The encoding of source files.
5757
# source_encoding = 'utf-8-sig'
5858

5959
# The master toctree document.
60-
master_doc = 'index'
60+
master_doc = "index"
6161

6262
# General information about the project.
63-
project = u'django-treebeard'
64-
copyright = u'2016, Gustavo Picón'
65-
author = u'Gustavo Picón'
63+
project = "django-treebeard"
64+
copyright = "2016, Gustavo Picón"
65+
author = "Gustavo Picón"
6666

6767
# The version info for the project you're documenting, acts as replacement for
6868
# |version| and |release|, also used in various other places throughout the
6969
# built documents.
7070
#
7171
# The short X.Y version.
72-
version = '4'
72+
version = "4"
7373
# The full version, including alpha/beta/rc tags.
74-
release = '4.7'
74+
release = "4.7"
7575

7676
# The language for content autogenerated by Sphinx. Refer to documentation
7777
# for a list of supported languages.
@@ -106,7 +106,7 @@
106106
# show_authors = False
107107

108108
# The name of the Pygments (syntax highlighting) style to use.
109-
pygments_style = 'sphinx'
109+
pygments_style = "sphinx"
110110

111111
# A list of ignored prefixes for module index sorting.
112112
# modindex_common_prefix = []
@@ -122,7 +122,7 @@
122122

123123
# The theme to use for HTML and HTML Help pages. See the documentation for
124124
# a list of builtin themes.
125-
html_theme = 'default'
125+
html_theme = "default"
126126

127127
# Theme options are theme-specific and customize the look and feel of a theme
128128
# further. For a list of options available for each theme, see the
@@ -151,7 +151,7 @@
151151
# Add any paths that contain custom static files (such as style sheets) here,
152152
# relative to this directory. They are copied after the builtin static files,
153153
# so a file named "default.css" will overwrite the builtin "default.css".
154-
html_static_path = ['_static']
154+
html_static_path = ["_static"]
155155

156156
# Add any extra paths that contain custom files (such as robots.txt or
157157
# .htaccess) here, relative to this directory. These files are copied
@@ -214,30 +214,26 @@
214214
# html_search_scorer = 'scorer.js'
215215

216216
# Output file base name for HTML help builder.
217-
htmlhelp_basename = 'django-treebearddoc'
217+
htmlhelp_basename = "django-treebearddoc"
218218

219219
# -- Options for LaTeX output ---------------------------------------------
220220

221221
latex_elements = {
222-
# The paper size ('letterpaper' or 'a4paper').
223-
# 'papersize': 'letterpaper',
224-
225-
# The font size ('10pt', '11pt' or '12pt').
226-
# 'pointsize': '10pt',
227-
228-
# Additional stuff for the LaTeX preamble.
229-
# 'preamble': '',
230-
231-
# Latex figure (float) alignment
232-
# 'figure_align': 'htbp',
222+
# The paper size ('letterpaper' or 'a4paper').
223+
# 'papersize': 'letterpaper',
224+
# The font size ('10pt', '11pt' or '12pt').
225+
# 'pointsize': '10pt',
226+
# Additional stuff for the LaTeX preamble.
227+
# 'preamble': '',
228+
# Latex figure (float) alignment
229+
# 'figure_align': 'htbp',
233230
}
234231

235232
# Grouping the document tree into LaTeX files. List of tuples
236233
# (source start file, target name, title,
237234
# author, documentclass [howto, manual, or own class]).
238235
latex_documents = [
239-
(master_doc, 'django-treebeard.tex', u'django-treebeard Documentation',
240-
u'Gustavo Picón', 'manual'),
236+
(master_doc, "django-treebeard.tex", "django-treebeard Documentation", "Gustavo Picón", "manual"),
241237
]
242238

243239
# The name of an image file (relative to this directory) to place at the top of
@@ -265,10 +261,7 @@
265261

266262
# One entry per manual page. List of tuples
267263
# (source start file, name, description, authors, manual section).
268-
man_pages = [
269-
(master_doc, 'django-treebeard', u'django-treebeard Documentation',
270-
[author], 1)
271-
]
264+
man_pages = [(master_doc, "django-treebeard", "django-treebeard Documentation", [author], 1)]
272265

273266
# If true, show URL addresses after external links.
274267
# man_show_urls = False
@@ -280,9 +273,15 @@
280273
# (source start file, target name, title, author,
281274
# dir menu entry, description, category)
282275
texinfo_documents = [
283-
(master_doc, 'django-treebeard', u'django-treebeard Documentation',
284-
author, 'django-treebeard', 'One line description of project.',
285-
'Miscellaneous'),
276+
(
277+
master_doc,
278+
"django-treebeard",
279+
"django-treebeard Documentation",
280+
author,
281+
"django-treebeard",
282+
"One line description of project.",
283+
"Miscellaneous",
284+
),
286285
]
287286

288287
# Documents to append as an appendix to all manuals.
@@ -298,6 +297,6 @@
298297
# texinfo_no_detailmenu = False
299298

300299
intersphinx_mapping = {
301-
'django': ('https://docs.djangoproject.com/en/stable/', 'https://docs.djangoproject.com/en/stable/_objects/'),
302-
'python': ('https://docs.python.org/3.13', None),
300+
"django": ("https://docs.djangoproject.com/en/stable/", "https://docs.djangoproject.com/en/stable/_objects/"),
301+
"python": ("https://docs.python.org/3.13", None),
303302
}

pyproject.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,17 @@ dependencies = [
4040
test = [
4141
"pytest-django>=4.0,<5.0",
4242
"pytest-pythonpath>=0.7,<1.0",
43+
]
44+
45+
[tool.ruff]
46+
line-length = 120
47+
lint.ignore = [
48+
"UP031" # Allow percent formatters
49+
]
50+
lint.select = [
51+
"PLE", # pylint errors
52+
"UP", # pyupgrade
53+
"I", # isort
54+
"F", # pyflakes
55+
"E", # pycodestyle errors
4356
]

tests/admin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import itertools
22

33
from django.contrib import admin
4+
5+
from tests.models import BASE_MODELS, DEP_MODELS, UNICODE_MODELS
46
from treebeard.admin import admin_factory
57
from treebeard.forms import movenodeform_factory
68

7-
from tests.models import BASE_MODELS, UNICODE_MODELS, DEP_MODELS
8-
99

1010
def register(admin_site, model):
1111
form_class = movenodeform_factory(model)

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
"""Pytest configuration file
2-
"""
1+
"""Pytest configuration file"""
2+
33
import os
44

55
os.environ["DJANGO_SETTINGS_MODULE"] = "tests.settings"

0 commit comments

Comments
 (0)