Skip to content

Commit

Permalink
fix(hooks): Fix ruff version used in commit hooks
Browse files Browse the repository at this point in the history
The project uses 0.4.9, per requirements.txt. Use that version in hook
too to avoid getting result in CI than what is produced in local.

- Move deprecated top-level linter settings to .lint subsection.
- Rename PGH002 to G010 as that preferred.
  • Loading branch information
jlaunonen committed Jun 18, 2024
1 parent 53b066f commit 43b013f
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ minimum_pre_commit_version: 2.15.0

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.13"
rev: "v0.4.9"
hooks:
- id: ruff
args:
Expand Down
5 changes: 2 additions & 3 deletions backend/core/management/commands/core_update_maysendinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def handle(self, *args, **options):
users = User.objects.filter(person__may_send_info=True)
group.user_set.set(users, clear=True)
logger.info(
"{num_users} users will now receive info spam".format(
num_users=Group.objects.get(name=settings.KOMPASSI_MAY_SEND_INFO_GROUP_NAME).user_set.count(),
)
"%d users will now receive info spam",
Group.objects.get(name=settings.KOMPASSI_MAY_SEND_INFO_GROUP_NAME).user_set.count(),
)
1 change: 1 addition & 0 deletions backend/forms/utils/process_form_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
NOTE: The exact semantics of `process_form_data` are defined by and documented in
`forms/tests.py:test_process_form_data`.
"""

import decimal
from collections.abc import Sequence
from enum import Enum
Expand Down
6 changes: 3 additions & 3 deletions backend/kompassi/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,9 @@ def mkpath(*parts):

KOMPASSI_APPLICATION_NAME = "Kompassi"
KOMPASSI_INSTALLATION_NAME = env("KOMPASSI_INSTALLATION_NAME", default="Kompassi (DEV)")
KOMPASSI_INSTALLATION_NAME_ILLATIVE = "Kompassin kehitys\u00ADinstanssiin" if DEBUG else "Kompassiin"
KOMPASSI_INSTALLATION_NAME_GENITIVE = "Kompassin kehitys\u00ADinstanssin" if DEBUG else "Kompassin"
KOMPASSI_INSTALLATION_NAME_PARTITIVE = "Kompassin kehitys\u00ADinstanssia" if DEBUG else "Kompassia"
KOMPASSI_INSTALLATION_NAME_ILLATIVE = "Kompassin kehitys\u00adinstanssiin" if DEBUG else "Kompassiin"
KOMPASSI_INSTALLATION_NAME_GENITIVE = "Kompassin kehitys\u00adinstanssin" if DEBUG else "Kompassin"
KOMPASSI_INSTALLATION_NAME_PARTITIVE = "Kompassin kehitys\u00adinstanssia" if DEBUG else "Kompassia"
KOMPASSI_INSTALLATION_SLUG = env("KOMPASSI_INSTALLATION_SLUG", default="turskadev")
KOMPASSI_PRIVACY_POLICY_URL = "https://ry.tracon.fi/tietosuoja/rekisteriselosteet/kompassi"
FEEDBACK_PRIVACY_POLICY_URL = "https://ry.tracon.fi/tietosuoja/rekisteriselosteet/kompassi-palaute"
Expand Down
7 changes: 1 addition & 6 deletions backend/labour/models/roster.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,7 @@ def get_csv_related(self):

def __str__(self):
parts = [
"{interval} ({hours} h): {job_category_name} ({job_name})".format(
interval=format_interval(self.start_time, self.end_time),
hours=self.hours,
job_category_name=self.job.job_category.title if self.job and self.job.job_category else None,
job_name=self.job.title if self.job else None,
)
f"{format_interval(self.start_time, self.end_time)} ({self.hours} h): {self.job.job_category.title if self.job and self.job.job_category else None} ({self.job.title if self.job else None})"
]

if self.notes:
Expand Down
5 changes: 1 addition & 4 deletions backend/membership/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,7 @@ def to_html_print(self):
return f"{self.person.surname}, {self.person.official_first_names}, {self.person.muncipality}"

def __str__(self):
return "{organization}/{person}".format(
organization=self.organization.name if self.organization else None,
person=self.person.official_name if self.person else None,
)
return f"{self.organization.name if self.organization else None}/{self.person.official_name if self.person else None}"

@classmethod
def get_csv_fields(cls, unused_organization):
Expand Down
6 changes: 4 additions & 2 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ line-length = 120
[tool.ruff]
target-version = "py312"
line-length = 120

[tool.ruff.lint]
ignore-init-module-imports = true
extend-select = [
"B",
"C",
"I", # import sorting
"PERF",
"PGH002", # .warn is deprecated
"G010", # .warn is deprecated
"PGH004", # specific noqa
"PL", # pylint
"RET",
Expand Down Expand Up @@ -38,7 +40,7 @@ extend-ignore = [
"PERF401", # manual-list-comprehension
]

[tool.ruff.extend-per-file-ignores]
[tool.ruff.lint.extend-per-file-ignores]
"**/__init__.py" = [
"F401", # imported but unused
]
Expand Down

0 comments on commit 43b013f

Please sign in to comment.