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 3a08304
Show file tree
Hide file tree
Showing 21 changed files with 19 additions and 33 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@ 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"]
- 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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ sankey = [
[tool.ruff]

line-length = 120

[tool.ruff.lint]
select = [
"E", # pycodestyle
"F", # pyflakes
Expand Down
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
1 change: 0 additions & 1 deletion survey/management/commands/exportresult.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@


class Command(SurveyCommand):

"""
See the "help" var.
"""
Expand Down
1 change: 0 additions & 1 deletion survey/management/commands/generatetexconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Command(SurveyCommand):

"""
See the "help" var.
"""
Expand Down
2 changes: 1 addition & 1 deletion survey/models/question.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion survey/models/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@


class Response(models.Model):

"""
A Response object is a collection of questions and answers with a
unique interview uuid.
Expand Down
1 change: 0 additions & 1 deletion survey/tests/exporter/csv/test_survey2csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class TestSurvey2Csv(TestManagement):

"""Permit to check if export result is working as intended."""

def setUp(self):
Expand Down
1 change: 0 additions & 1 deletion survey/tests/management/commands/test_exportresult.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


class TestExportresult(TestManagement):

"""Permit to check if export result is working as intended."""

def get_csv_path(self, survey_name):
Expand Down
1 change: 0 additions & 1 deletion survey/tests/management/test_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 0 additions & 1 deletion survey/tests/test_survey_auth_required.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class TestSurveyAuthRequired(BaseTest):

"""Permit to check if need_logged_user is working as intended."""

def assert_accessible(self, url):
Expand Down

0 comments on commit 3a08304

Please sign in to comment.