diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index df4993de..822bf165 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,19 +3,19 @@ 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/psf/black - rev: 23.12.0 + rev: 24.10.0 hooks: - id: black args: [--line-length, "120"] @@ -23,8 +23,8 @@ repos: 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] diff --git a/example_project/example_project/urls.py b/example_project/example_project/urls.py index 505e9be6..180436c7 100644 --- a/example_project/example_project/urls.py +++ b/example_project/example_project/urls.py @@ -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: diff --git a/pyproject.toml b/pyproject.toml index 472b8044..d15f51ac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,7 +72,7 @@ sankey = [ [tool.ruff] line-length = 120 - +[tool.ruff.lint] select = [ "E", # pycodestyle "F", # pyflakes diff --git a/survey/apps.py b/survey/apps.py index 413502a0..68414965 100644 --- a/survey/apps.py +++ b/survey/apps.py @@ -2,7 +2,6 @@ class DjangoSurveyAndReportConfig(AppConfig): - """ See https://docs.djangoproject.com/en/2.1/ref/applications/#django.apps.AppConfig """ diff --git a/survey/exporter/survey2x.py b/survey/exporter/survey2x.py index 63d42f8a..5fceabdd 100755 --- a/survey/exporter/survey2x.py +++ b/survey/exporter/survey2x.py @@ -14,7 +14,6 @@ class Survey2X: - """Abstract class for Survey exporter.""" def __init__(self, survey=None): diff --git a/survey/exporter/tex/configuration.py b/survey/exporter/tex/configuration.py index 93db6460..3e3ad210 100755 --- a/survey/exporter/tex/configuration.py +++ b/survey/exporter/tex/configuration.py @@ -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): diff --git a/survey/exporter/tex/configuration_builder.py b/survey/exporter/tex/configuration_builder.py index de1f26c0..06071807 100755 --- a/survey/exporter/tex/configuration_builder.py +++ b/survey/exporter/tex/configuration_builder.py @@ -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 diff --git a/survey/exporter/tex/latex_file.py b/survey/exporter/tex/latex_file.py index 6c85958d..b1d970cc 100755 --- a/survey/exporter/tex/latex_file.py +++ b/survey/exporter/tex/latex_file.py @@ -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): @@ -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 diff --git a/survey/exporter/tex/question2tex.py b/survey/exporter/tex/question2tex.py index 811dd8b7..111154ee 100755 --- a/survey/exporter/tex/question2tex.py +++ b/survey/exporter/tex/question2tex.py @@ -10,7 +10,6 @@ class Question2Tex: - """ This class permit to generate latex code directly from the Question object after overriding the tex() function. diff --git a/survey/exporter/tex/question2tex_chart.py b/survey/exporter/tex/question2tex_chart.py index 26ba84b4..de805835 100755 --- a/survey/exporter/tex/question2tex_chart.py +++ b/survey/exporter/tex/question2tex_chart.py @@ -9,7 +9,6 @@ class Question2TexChart(Question2Tex): - """ This class permit to generate latex code directly from the Question object. @@ -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.""" @@ -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: diff --git a/survey/exporter/tex/question2tex_raw.py b/survey/exporter/tex/question2tex_raw.py index 3994fd0b..5a3be685 100755 --- a/survey/exporter/tex/question2tex_raw.py +++ b/survey/exporter/tex/question2tex_raw.py @@ -4,7 +4,6 @@ class Question2TexRaw(Question2Tex): - """ This class permit to generate latex code directly from the Question object. diff --git a/survey/exporter/tex/question2tex_sankey.py b/survey/exporter/tex/question2tex_sankey.py index 1633f205..84913be2 100755 --- a/survey/exporter/tex/question2tex_sankey.py +++ b/survey/exporter/tex/question2tex_sankey.py @@ -29,7 +29,6 @@ def __init__(self): class Question2TexSankey(Question2Tex): - """ This class permit to generate latex code directly from the Question object. diff --git a/survey/exporter/tex/survey2tex.py b/survey/exporter/tex/survey2tex.py index c4d82883..8960894e 100755 --- a/survey/exporter/tex/survey2tex.py +++ b/survey/exporter/tex/survey2tex.py @@ -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()) diff --git a/survey/management/commands/exportresult.py b/survey/management/commands/exportresult.py index 04c2b5aa..c47ad87c 100755 --- a/survey/management/commands/exportresult.py +++ b/survey/management/commands/exportresult.py @@ -12,7 +12,6 @@ class Command(SurveyCommand): - """ See the "help" var. """ diff --git a/survey/management/commands/generatetexconf.py b/survey/management/commands/generatetexconf.py index 601f886e..054d35ef 100755 --- a/survey/management/commands/generatetexconf.py +++ b/survey/management/commands/generatetexconf.py @@ -5,7 +5,6 @@ class Command(SurveyCommand): - """ See the "help" var. """ diff --git a/survey/models/question.py b/survey/models/question.py index f557197d..e9d6125c 100644 --- a/survey/models/question.py +++ b/survey/models/question.py @@ -280,7 +280,7 @@ def sorted_answers_cardinality( user_defined = isinstance(sort_answer, dict) valid = user_defined or sort_answer in possibles_values if not valid: - msg = "Unrecognized option '%s' for 'sort_answer': " % sort_answer + msg = f"Unrecognized option '{sort_answer}' for 'sort_answer': " msg += "use nothing, a dict (answer: rank)," for option in possibles_values: msg += f" '{option}', or" diff --git a/survey/models/response.py b/survey/models/response.py index 6d5c1425..2da0d37f 100644 --- a/survey/models/response.py +++ b/survey/models/response.py @@ -16,7 +16,6 @@ class Response(models.Model): - """ A Response object is a collection of questions and answers with a unique interview uuid. diff --git a/survey/tests/exporter/csv/test_survey2csv.py b/survey/tests/exporter/csv/test_survey2csv.py index 7c765b65..2624d579 100755 --- a/survey/tests/exporter/csv/test_survey2csv.py +++ b/survey/tests/exporter/csv/test_survey2csv.py @@ -5,7 +5,6 @@ class TestSurvey2Csv(TestManagement): - """Permit to check if export result is working as intended.""" def setUp(self): diff --git a/survey/tests/management/commands/test_exportresult.py b/survey/tests/management/commands/test_exportresult.py index c0a5360a..e1fa991f 100755 --- a/survey/tests/management/commands/test_exportresult.py +++ b/survey/tests/management/commands/test_exportresult.py @@ -10,7 +10,6 @@ class TestExportresult(TestManagement): - """Permit to check if export result is working as intended.""" def get_csv_path(self, survey_name): diff --git a/survey/tests/management/test_management.py b/survey/tests/management/test_management.py index a6fee9b2..7c634d9a 100755 --- a/survey/tests/management/test_management.py +++ b/survey/tests/management/test_management.py @@ -9,7 +9,6 @@ class TestManagement(BaseTest): - """Permit to check if export result is working as intended.""" def create_answers(self, username, a1, a2, a3): diff --git a/survey/tests/test_survey_auth_required.py b/survey/tests/test_survey_auth_required.py index 8a4c62c6..812ccadb 100755 --- a/survey/tests/test_survey_auth_required.py +++ b/survey/tests/test_survey_auth_required.py @@ -6,7 +6,6 @@ class TestSurveyAuthRequired(BaseTest): - """Permit to check if need_logged_user is working as intended.""" def assert_accessible(self, url):