Skip to content

Commit

Permalink
[pre-commit] Upgrade tooling
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Sassoulas committed Oct 28, 2024
1 parent d260394 commit 574e6aa
Show file tree
Hide file tree
Showing 33 changed files with 431 additions and 437 deletions.
14 changes: 9 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,32 @@ ci:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: check-merge-conflict
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-json
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.8"
rev: "v0.7.1"
hooks:
- id: ruff
args: ["--fix"]
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "2.3.1"
hooks:
- id: pyproject-fmt
- repo: https://github.com/psf/black
rev: 23.12.0
rev: 24.10.0
hooks:
- id: black
args: [--line-length, "120"]
- repo: https://github.com/Pierre-Sassoulas/black-disable-checker/
rev: v1.1.3
hooks:
- id: black-disable-checker
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.3.3
hooks:
- id: prettier
args: [--prose-wrap=always, --print-width=88]
Expand Down
1 change: 1 addition & 0 deletions example_project/example_project/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""

from django.conf.urls import include

try:
Expand Down
184 changes: 91 additions & 93 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,121 +1,119 @@
[build-system]
requires = ["setuptools>=67.5.1", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools.packages.find]
include = ["survey*"]
requires = [ "setuptools>=67.5.1", "wheel" ]

[project]
name = "django-survey-and-report"
description = "A django survey app that can export results as CSV or PDF using your native language."
version = "1.4.8"
description = "A django survey app that can export results as CSV or PDF using your native language."
readme = "README.md"
license = { text = "AGPL-3.0" }
authors = [
{email="[email protected]", name="Pierre SASSOULAS"}
{ email = "[email protected]", name = "Pierre SASSOULAS" },
]
license = {text = "AGPL-3.0"}
classifiers = [
"Development Status :: 5 - Production/Stable",
"Natural Language :: English",
"Natural Language :: Russian",
"Natural Language :: Spanish",
"Natural Language :: French",
"Natural Language :: Japanese",
"Natural Language :: Dutch",
"Natural Language :: Chinese (Traditional)",
"Natural Language :: German",
"Natural Language :: Indonesian",
"Natural Language :: Portuguese",
"Natural Language :: Polish",
"Topic :: Utilities",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Affero General Public License v3",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Framework :: Django"
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Framework :: Django",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Affero General Public License v3",
"Natural Language :: Chinese (Traditional)",
"Natural Language :: Dutch",
"Natural Language :: English",
"Natural Language :: French",
"Natural Language :: German",
"Natural Language :: Indonesian",
"Natural Language :: Japanese",
"Natural Language :: Polish",
"Natural Language :: Portuguese",
"Natural Language :: Russian",
"Natural Language :: Spanish",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Utilities",
]
dependencies = [
"django>=2.2,<5",
"django-bootstrap-form>=3.4",
"django-tastypie>=0.14.2",
"django-registration>=3.0",
"pytz>=2018.9",
"ordereddict>=1.1",
"pyyaml>=4.2b1",
"django>=2.2,<5",
"django-bootstrap-form>=3.4",
"django-registration>=3",
"django-tastypie>=0.14.2",
"ordereddict>=1.1",
"pytz>=2018.9",
"pyyaml>=4.2b1",
]

[project.urls]
"Source Code" = "https://github.com/Pierre-Sassoulas/django-survey"
"Bug Tracker" = "https://github.com/Pierre-Sassoulas/django-survey/issues"

[project.optional-dependencies]
dev = [
"pySankeyBeta~=1.3.0",
"django-rosetta",
"coverage",
"python-coveralls",
"coveralls",
"colorama",
"pylint",
"pylint-django",
"pre-commit"
optional-dependencies.dev = [
"colorama",
"coverage",
"coveralls",
"django-rosetta",
"pre-commit",
"pylint>=3.3.1",
"pylint-django",
"pysankeybeta~=1.3.0",
"python-coveralls",
]
sankey = [
"pySankeyBeta~=1.3.0",
optional-dependencies.sankey = [
"pysankeybeta~=1.3.0",
]
urls."Bug Tracker" = "https://github.com/Pierre-Sassoulas/django-survey/issues"
urls."Source Code" = "https://github.com/Pierre-Sassoulas/django-survey"

[tool.setuptools.packages.find]
include = [ "survey*" ]

[tool.ruff]

line-length = 120

select = [
"E", # pycodestyle
"F", # pyflakes
"W", # pycodestyle
"B", # bugbear
"I", # isort
"RUF", # ruff
"UP", # pyupgrade
lint.select = [
"B", # bugbear
"E", # pycodestyle
"F", # pyflakes
"I", # isort
"RUF", # ruff
"UP", # pyupgrade
"W", # pycodestyle
]

ignore = [
"RUF012", # mutable default values in class attributes
lint.ignore = [
"RUF012", # mutable default values in class attributes
]

[tool.pylint.main]
load-plugins ="pylint_django"
load-plugins = "pylint_django"

disable=[
# I0011 Warning locally suppressed using disable-msg
"I0011",
"no-member",
"missing-docstring", # We don't want docstring everywhere
"too-few-public-methods", # More harmful than beneficial in django project
"too-many-arguments",
"too-many-instance-attributes",
# TODO Fix
"unspecified-encoding",
"inconsistent-return-statements",
"consider-using-with",
"fixme",
"no-else-return",
"imported-auth-user",
"unused-argument",
"arguments-differ",
"consider-using-f-string",
"too-many-branches",
"redefined-builtin",
"superfluous-parens",
"useless-parent-delegation",
"unused-private-member",
"duplicate-code",
"attribute-defined-outside-init",
disable = [
# I0011 Warning locally suppressed using disable-msg
"I0011",
"no-member",
"missing-docstring", # We don't want docstring everywhere
"too-few-public-methods", # More harmful than beneficial in django project
"too-many-arguments",
"too-many-instance-attributes",
# TODO Fix
"too-many-positional-arguments", # Bad API
"unspecified-encoding",
"inconsistent-return-statements",
"consider-using-with",
"fixme",
"no-else-return",
"imported-auth-user",
"unused-argument",
"arguments-differ",
"consider-using-f-string",
"too-many-branches",
"redefined-builtin",
"superfluous-parens",
"useless-parent-delegation",
"unused-private-member",
"duplicate-code",
"attribute-defined-outside-init",
]
ignore="migrations"
good-names="i,j,k,ex,Run,_,f,e,maxDiff"
ignore = "migrations"
good-names = "i,j,k,ex,Run,_,f,e,maxDiff"
max-line-length = 120
1 change: 0 additions & 1 deletion survey/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


class DjangoSurveyAndReportConfig(AppConfig):

"""
See https://docs.djangoproject.com/en/2.1/ref/applications/#django.apps.AppConfig
"""
Expand Down
1 change: 0 additions & 1 deletion survey/exporter/survey2x.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@


class Survey2X:

"""Abstract class for Survey exporter."""

def __init__(self, survey=None):
Expand Down
2 changes: 1 addition & 1 deletion survey/exporter/tex/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def _init_from_file(self, filepath):
for survey_name in list(configuration.keys()):
self.check_survey_exists(survey_name)
if not configuration[survey_name]:
raise ValueError("Nothing in %s's configuration" % survey_name)
raise ValueError(f"Nothing in {survey_name}'s configuration")
return configuration

def optional_update(self, dict_, update_dict, key):
Expand Down
1 change: 0 additions & 1 deletion survey/exporter/tex/configuration_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class ConfigurationBuilder(Configuration):

"""
Permit to create serializable uninitialized configuration easily.
We just use the default dict for a Builder, the user will be able to
Expand Down
9 changes: 4 additions & 5 deletions survey/exporter/tex/latex_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class LatexFile:

"""Permit to handle the content of a LatexFile"""

def __init__(self, document_class, document_option=None, header=None, intro=None, footer=None, date=None, **kwargs):
Expand Down Expand Up @@ -36,11 +35,11 @@ def header(self):
header = "\\documentclass"
if self.document_option:
header += f"[{self.document_option}]"
header += "{%s}\n" % self.document_class
header += "\\date{%s}\n" % self.date
header += "%s\n" % self._header
header += f"{{{self.document_class}}}\n"
header += f"\\date{{{self.date}}}\n"
header += f"{self._header}\n"
header += "\\begin{document}\n"
header += "%s\n" % self.intro
header += f"{self.intro}\n"
return header

@property
Expand Down
1 change: 0 additions & 1 deletion survey/exporter/tex/question2tex.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


class Question2Tex:

"""
This class permit to generate latex code directly from the Question
object after overriding the tex() function.
Expand Down
11 changes: 5 additions & 6 deletions survey/exporter/tex/question2tex_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@


class Question2TexChart(Question2Tex):

"""
This class permit to generate latex code directly from the Question
object.
Expand Down Expand Up @@ -52,11 +51,11 @@ def get_colors(self):
try:
colors.append(self.color[answer])
except (KeyError, ValueError):
msg = "Color for '%s' not provided. You could " % answer
msg += "add '%s: \"red!50\"', in your color config." % answer
msg = f"Color for '{answer}' not provided. You could "
msg += f"add '{answer}: \"red!50\"', in your color config."
LOGGER.warning(msg)
colors.append(settings.SURVEY_DEFAULT_PIE_COLOR)
return "{%s}" % ", ".join(colors)
return "{{{}}}".format(", ".join(colors))

def get_results(self):
"""Return a formatted string for a tikz pgf-pie chart."""
Expand All @@ -78,9 +77,9 @@ def get_pie_options(self):
r"""Return the options of the pie for: \pie[options]{data}"""
options = ""
if self.pos:
options += "pos={%s}," % self.pos
options += f"pos={{{self.pos}}},"
if self.explode:
options += "explode={%s}," % self.explode
options += f"explode={{{self.explode}}},"
if self.rotate:
options += f"rotate={self.rotate},"
if self.radius:
Expand Down
1 change: 0 additions & 1 deletion survey/exporter/tex/question2tex_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Question2TexRaw(Question2Tex):

"""
This class permit to generate latex code directly from the Question
object.
Expand Down
1 change: 0 additions & 1 deletion survey/exporter/tex/question2tex_sankey.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def __init__(self):


class Question2TexSankey(Question2Tex):

"""
This class permit to generate latex code directly from the Question
object.
Expand Down
2 changes: 1 addition & 1 deletion survey/exporter/tex/survey2tex.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def export_as_tex(modeladmin, request, queryset):
try:
s2tex.generate_pdf()
except subprocess.CalledProcessError as exc:
modeladmin.message_user(request, _("Error during PDF generation: %s" % exc), level=ERROR)
modeladmin.message_user(request, _("Error during PDF generation: {}".format(exc)), level=ERROR)
return
with open(s2tex.pdf_filename, "rb") as f:
response.write(f.read())
Expand Down
Loading

0 comments on commit 574e6aa

Please sign in to comment.