Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruff linter/formatter #338

Merged
merged 5 commits into from
Feb 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,24 @@ Visit [http://127.0.0.1:8000](http://127.0.0.1:8000)

For detailed setup docs, see [spirit.readthedocs.io](http://spirit.readthedocs.io/en/latest/)

## Testing
## Dev

Use [uv tooling](https://docs.astral.sh/uv/).

### Testing

```
uv sync --all-extras
uv run runtests.py
```

### Lint & Format

```
ruff check --select I --fix
uvx ruff format
```

## License

MIT
74 changes: 38 additions & 36 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath('..'))

sys.path.insert(0, os.path.abspath(".."))
add_module_names = False
version = __import__('spirit').__version__
version = __import__("spirit").__version__
release = version


Expand All @@ -33,25 +34,24 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.githubpages']
extensions = ["sphinx.ext.autodoc", "sphinx.ext.githubpages"]

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

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

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = 'Spirit'
copyright = '2017, Esteban Castro Borsani'
author = 'Esteban Castro Borsani'
project = "Spirit"
copyright = "2017, Esteban Castro Borsani"
author = "Esteban Castro Borsani"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -63,10 +63,10 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
Expand All @@ -77,7 +77,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
html_theme = "alabaster"

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

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# This is required for the alabaster theme
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
html_sidebars = {
'**': [
'about.html',
'navigation.html',
'relations.html', # needs 'show_related': True theme option to display
'searchbox.html',
'donate.html',
"**": [
"about.html",
"navigation.html",
"relations.html", # needs 'show_related': True theme option to display
"searchbox.html",
"donate.html",
]
}


# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'Spiritdoc'
htmlhelp_basename = "Spiritdoc"


# -- Options for LaTeX output ---------------------------------------------
Expand All @@ -118,15 +118,12 @@
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -136,19 +133,21 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'Spirit.tex', 'Spirit Documentation',
'Esteban Castro Borsani', 'manual'),
(
master_doc,
"Spirit.tex",
"Spirit Documentation",
"Esteban Castro Borsani",
"manual",
)
]


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'spirit', 'Spirit Documentation',
[author], 1)
]
man_pages = [(master_doc, "spirit", "Spirit Documentation", [author], 1)]


# -- Options for Texinfo output -------------------------------------------
Expand All @@ -157,10 +156,13 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'Spirit', 'Spirit Documentation',
author, 'Spirit', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"Spirit",
"Spirit Documentation",
author,
"Spirit",
"One line description of project.",
"Miscellaneous",
)
]



18 changes: 17 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,23 @@ packages = ["spirit"]
version = { attr = "spirit.__version__" }

[tool.ruff]
line-length = 120
src = ["spirit"]
line-length = 88
extend-exclude = [
".git",
"*/migrations/",
"*settings*.py"
]

[tool.ruff.format]
skip-magic-trailing-comma = true

[tool.ruff.lint]
extend-select = ["E501"]

[tool.ruff.lint.flake8-annotations]
ignore-fully-untyped = true
mypy-init-return = true

[dependency-groups]
dev = [
Expand Down
16 changes: 8 additions & 8 deletions runtests.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
#!/usr/bin/env python


import logging
import os
import sys
import logging

import django
from django.test.runner import DiscoverRunner


os.environ['DJANGO_SETTINGS_MODULE'] = 'project.project.settings.test'
os.environ["DJANGO_SETTINGS_MODULE"] = "project.project.settings.test"


def setup_celery():
try:
from celery import Celery
except ImportError:
return
app = Celery('test')
app.config_from_object('django.conf:settings', namespace='CELERY')
app = Celery("test")
app.config_from_object("django.conf:settings", namespace="CELERY")
app.autodiscover_tasks()


def log_warnings():
logger = logging.getLogger('py.warnings')
logger = logging.getLogger("py.warnings")
handler = logging.StreamHandler()
logger.addHandler(handler)


def run_tests(reverse=False):
sys.stdout.write(
"\nRunning spirit test suite, using settings %(settings)r\n\n" %
{"settings": os.environ['DJANGO_SETTINGS_MODULE']})
"\nRunning spirit test suite, using settings %(settings)r\n\n"
% {"settings": os.environ["DJANGO_SETTINGS_MODULE"]}
)
return DiscoverRunner(reverse=reverse).run_tests([])


Expand Down
4 changes: 0 additions & 4 deletions setup.cfg

This file was deleted.

2 changes: 1 addition & 1 deletion spirit/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.13.0'
__version__ = "0.13.0"
6 changes: 3 additions & 3 deletions spirit/admin/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@


class SpiritAdminConfig(AppConfig):

name = 'spirit.admin'
name = "spirit.admin"
verbose_name = "Spirit Admin"
label = 'spirit_admin'
label = "spirit_admin"

def ready(self):
self.register_config()

def register_config(self):
import djconfig

from .forms import BasicConfigForm

djconfig.register(BasicConfigForm)
22 changes: 13 additions & 9 deletions spirit/admin/forms.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
from django import forms
from django.utils.translation import gettext_lazy as _

from djconfig.forms import ConfigForm


class BasicConfigForm(ConfigForm):

site_name = forms.CharField(initial="Spirit", label=_("site name"))
site_description = forms.CharField(
initial="", label=_("site description"), max_length=75, required=False)
initial="", label=_("site description"), max_length=75, required=False
)
template_footer = forms.CharField(
initial="", label=_("footer snippet"), required=False,
widget=forms.Textarea(attrs={'rows': 2}),
initial="",
label=_("footer snippet"),
required=False,
widget=forms.Textarea(attrs={"rows": 2}),
help_text=(
"The footer snippet is no longer supported and "
"it will be removed in future Spirit versions"))
"The footer snippet is no longer supported and it will be removed in future Spirit versions"
),
)
comments_per_page = forms.IntegerField(
initial=20, label=_("comments per page"), min_value=1, max_value=100)
initial=20, label=_("comments per page"), min_value=1, max_value=100
)
topics_per_page = forms.IntegerField(
initial=20, label=_("topics per page"), min_value=1, max_value=100)
initial=20, label=_("topics per page"), min_value=1, max_value=100
)
Loading