Skip to content

Commit da82629

Browse files
committed
update linters, do linting
1 parent e3a3484 commit da82629

File tree

19 files changed

+43
-43
lines changed

19 files changed

+43
-43
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ default_language_version:
44
exclude: "^.*\b(migrations)\b.*$"
55
repos:
66
- repo: "https://github.com/adamchainz/django-upgrade"
7-
rev: "1.24.0"
7+
rev: "1.30.0"
88
hooks:
99
- id: "django-upgrade"
1010
args: ['--target-version', '5.1']
1111
- repo: "https://github.com/astral-sh/ruff-pre-commit"
12-
rev: "v0.11.8"
12+
rev: "v0.15.4"
1313
hooks:
1414
- id: "ruff"
1515
args: ["--fix"]
1616
- id: "ruff-format"
1717
- repo: "https://github.com/pre-commit/mirrors-mypy"
18-
rev: 'v1.15.0'
18+
rev: 'v1.19.1'
1919
hooks:
2020
- id: "mypy"
2121
exclude: "src/.*/migrations/.*.py"

src/bornhack_allauth_provider/adapters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def populate_user(self, request: HttpRequest, sociallogin: SocialLogin, data: di
3434
user_username(sociallogin.user, data.get("username"))
3535

3636
# set initial handle on the user object to the bornhack preferred_username if one is set
37-
user_field(sociallogin.user, "handle", data["handle"] if data["handle"] else str(sociallogin.user.uuid))
37+
user_field(sociallogin.user, "handle", data["handle"] or str(sociallogin.user.uuid))
3838

3939
# set initial display_name on the user object to the bornhack profiles public_credit_name
4040
user_field(sociallogin.user, "display_name", data["public_credit_name"])

src/files/api.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,15 @@ def upload( # noqa: C901,PLR0913
8787

8888
Model: type[Image | Video | Audio | Document] # noqa: N806
8989
if data["mimetype"] in settings.ALLOWED_IMAGE_TYPES:
90-
from images.models import Image as Model
90+
from images.models import Image as Model # noqa: PLC0415
9191

9292
data["aspect_ratio"] = Fraction(data["width"], data["height"])
9393
elif data["mimetype"] in settings.ALLOWED_VIDEO_TYPES:
94-
from videos.models import Video as Model
94+
from videos.models import Video as Model # noqa: PLC0415
9595
elif data["mimetype"] in settings.ALLOWED_AUDIO_TYPES:
96-
from audios.models import Audio as Model
96+
from audios.models import Audio as Model # noqa: PLC0415
9797
elif data["mimetype"] in settings.ALLOWED_DOCUMENT_TYPES:
98-
from documents.models import Document as Model
98+
from documents.models import Document as Model # noqa: PLC0415
9999
else:
100100
return 422, {"message": "File type not supported"}
101101

src/files/managers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def prefetch_active_albums_list(self, *, recursive: bool = True) -> Self:
120120
If recursive is True then each prefetched album also gets a prefetch list of active files.
121121
"""
122122
# late import to avoid circular import
123-
from albums.models import Album
123+
from albums.models import Album # noqa: PLC0415
124124

125125
if recursive:
126126
qs = (

src/files/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def license_url(self) -> str:
234234
@property
235235
def source(self) -> str:
236236
"""Consider the BMA canonical URL the source if no other source has been specified."""
237-
return self.original_source if self.original_source else self.get_absolute_url()
237+
return self.original_source or self.get_absolute_url()
238238

239239
def get_absolute_url(self) -> str:
240240
"""The detail url for the file."""
@@ -392,7 +392,7 @@ def create_thumbnail_jobs(self) -> None:
392392
continue
393393

394394
# file missing, an unfinished job to create one should exist
395-
job, created = ThumbnailJob.objects.get_or_create(
395+
job, _created = ThumbnailJob.objects.get_or_create(
396396
basefile=self,
397397
width=version.width,
398398
height=version.height,

src/hitcounter/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,4 @@ def get_ip(request: HttpRequest) -> str:
113113
# this will raise an exception if the IP is not valid
114114
validate_ip(ip_address.strip())
115115
# all good
116-
return ip_address
116+
return str(ip_address)

src/images/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def create_fullsize_version_jobs(self) -> None:
117117
if self.get_fullsize_version(mimetype=mimetype):
118118
continue
119119
# create job for this filetype
120-
job, created = ImageConversionJob.objects.get_or_create(
120+
ImageConversionJob.objects.get_or_create(
121121
basefile=self,
122122
width=self.width,
123123
height=self.height,
@@ -129,7 +129,7 @@ def create_fullsize_version_jobs(self) -> None:
129129
def create_exif_job(self) -> None:
130130
"""Create exif data extraction job."""
131131
# get exif data?
132-
job, created = ImageExifExtractionJob.objects.get_or_create(
132+
ImageExifExtractionJob.objects.get_or_create(
133133
basefile=self,
134134
source_url=self.original.url,
135135
finished=False,
@@ -142,7 +142,7 @@ def create_smaller_version_jobs(self) -> None:
142142
if version.path.exists():
143143
continue
144144
# file missing, a new job must be created
145-
job, created = ImageConversionJob.objects.get_or_create(
145+
ImageConversionJob.objects.get_or_create(
146146
basefile=self,
147147
width=version.width,
148148
height=version.height,

src/jobs/managers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ class JobManager(RelatedPolymorphicManager):
1515

1616
def get_queryset(self) -> models.QuerySet["BaseJob"]: # type: ignore[override]
1717
"""Prefetch and annotate."""
18-
from jobs.models import ImageConversionJob
19-
from jobs.models import ThumbnailJob
20-
from jobs.models import ThumbnailSourceJob
18+
from jobs.models import ImageConversionJob # noqa: PLC0415
19+
from jobs.models import ThumbnailJob # noqa: PLC0415
20+
from jobs.models import ThumbnailSourceJob # noqa: PLC0415
2121

2222
return ( # type: ignore[no-any-return]
2323
super() # type: ignore[attr-defined]

src/jobs/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class ImageConversionJob(ImageJob):
178178

179179
def handle_result(self, f: UploadedFile, data: dict[str, str]) -> None:
180180
"""Save the result of an ImageConversionJob."""
181-
from images.models import ImageVersion
181+
from images.models import ImageVersion # noqa: PLC0415
182182

183183
# create model instance
184184
image = ImageVersion(
@@ -226,7 +226,7 @@ class ThumbnailSourceJob(BaseJob):
226226

227227
def handle_result(self, f: UploadedFile, data: dict[str, str]) -> None:
228228
"""Handle the result of a ThumbnailSourceJob."""
229-
from files.models import ThumbnailSource
229+
from files.models import ThumbnailSource # noqa: PLC0415
230230

231231
# delete any existing ThumbnailSource for this file
232232
ts = ThumbnailSource( # type: ignore[misc]
@@ -266,7 +266,7 @@ class ThumbnailJob(ImageJob):
266266

267267
def handle_result(self, f: UploadedFile, data: dict[str, str]) -> None:
268268
"""Save the result of a ThumbnailJob as a Thumbnail object."""
269-
from files.models import Thumbnail
269+
from files.models import Thumbnail # noqa: PLC0415
270270

271271
# set thumbnailsource FK?
272272
if hasattr(self.basefile, "thumbnailsource"):

src/jobs/tests/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def upload_result(self, job: dict[str, str], data: tuple[str, BytesIO] | BytesIO
196196
filepath: str | Path = settings.BASE_DIR / "static_src/images/file-video-solid.png"
197197
with Path(filepath).open("rb") as f:
198198
payload = {
199-
"data": data if data else f,
199+
"data": data or f,
200200
"client": json.dumps(
201201
{"client_uuid": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "client_version": "test-1.2.3"}
202202
),

0 commit comments

Comments
 (0)