Skip to content

Commit a03477c

Browse files
committed
chore: Update type-ignore comments
1 parent 7a33372 commit a03477c

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

modeltranslation/admin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def _get_declared_fieldsets(
4747
) -> _FieldsetSpec | None:
4848
# Take custom modelform fields option into account
4949
if not self.fields and hasattr(self.form, "_meta") and self.form._meta.fields:
50-
self.fields = self.form._meta.fields # type: ignore[misc]
50+
self.fields = self.form._meta.fields # type: ignore[assignment,misc]
5151
# takes into account non-standard add_fieldsets attribute used by UserAdmin
5252
fieldsets = (
5353
self.add_fieldsets
@@ -57,14 +57,14 @@ def _get_declared_fieldsets(
5757
if fieldsets:
5858
return self._patch_fieldsets(fieldsets)
5959
elif self.fields:
60-
return [(None, {"fields": self.replace_orig_field(self.get_fields(request, obj))})]
60+
return [(None, {"fields": self.replace_orig_field(self.get_fields(request, obj))})] # type: ignore[typeddict-item]
6161
return None
6262

6363
def _patch_fieldsets(self, fieldsets: _FieldsetSpec) -> _FieldsetSpec:
6464
fieldsets_new = list(fieldsets)
6565
for name, dct in fieldsets:
6666
if "fields" in dct:
67-
dct["fields"] = self.replace_orig_field(dct["fields"])
67+
dct["fields"] = self.replace_orig_field(dct["fields"]) # type: ignore[typeddict-item]
6868
return fieldsets_new
6969

7070
def formfield_for_dbfield(

modeltranslation/fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def create_translation_field(model: type[Model], field_name: str, lang: str, emp
8585

8686

8787
def field_factory(baseclass: type[fields.Field]) -> type[TranslationField]:
88-
class TranslationFieldSpecific(TranslationField, baseclass): # type: ignore[valid-type, misc]
88+
class TranslationFieldSpecific(TranslationField, baseclass): # type: ignore[valid-type]
8989
pass
9090

9191
# Reflect baseclass name of returned subclass

modeltranslation/manager.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def get_field_by_colum_name(model: type[Model], col: str) -> Field:
169169
return field
170170
except FieldDoesNotExist:
171171
pass
172-
field = _C2F_CACHE.get((model, col), None) # type: ignore[arg-type]
172+
field = _C2F_CACHE.get((model, col), None) # type: ignore[assignment]
173173
if field:
174174
return field
175175
# D'oh, need to search through all of them.
@@ -252,7 +252,7 @@ def select_related(self, *fields: Any, **kwargs: Any) -> Self:
252252
new_args.append(None)
253253
else:
254254
new_args.append(rewrite_lookup_key(self.model, key))
255-
return super().select_related(*new_args, **kwargs)
255+
return super().select_related(*new_args, **kwargs) # type: ignore[arg-type]
256256

257257
# This method was not present in django-linguo
258258
def _rewrite_col(self, col: Col) -> None:
@@ -277,11 +277,12 @@ def _rewrite_where(self, q: Lookup | Node) -> None:
277277
self._rewrite_col(q.lhs)
278278
if isinstance(q, Node):
279279
for child in q.children:
280-
self._rewrite_where(child)
280+
self._rewrite_where(child) # type: ignore[arg-type]
281281

282282
def _rewrite_order(self) -> None:
283283
self.query.order_by = [
284-
rewrite_order_lookup_key(self.model, field_name) for field_name in self.query.order_by
284+
rewrite_order_lookup_key(self.model, field_name) # type: ignore[arg-type]
285+
for field_name in self.query.order_by
285286
]
286287

287288
def _rewrite_select_related(self) -> None:
@@ -297,7 +298,7 @@ def _rewrite_q(self, q: Node | tuple[str, Any]) -> Any:
297298
if isinstance(q, tuple) and len(q) == 2:
298299
return rewrite_lookup_key(self.model, q[0]), q[1]
299300
if isinstance(q, Node):
300-
q.children = list(map(self._rewrite_q, q.children))
301+
q.children = list(map(self._rewrite_q, q.children)) # type: ignore[arg-type]
301302
return q
302303

303304
# This method was not present in django-linguo
@@ -309,7 +310,7 @@ def _rewrite_f(self, q: models.F | Node) -> models.F | Node:
309310
q.name = rewrite_lookup_key(self.model, q.name)
310311
return q
311312
if isinstance(q, Node):
312-
q.children = list(map(self._rewrite_f, q.children))
313+
q.children = list(map(self._rewrite_f, q.children)) # type: ignore[arg-type]
313314
# Django >= 1.8
314315
if hasattr(q, "lhs"):
315316
q.lhs = self._rewrite_f(q.lhs)

modeltranslation/translator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ def add_constraints():
356356
yield new_constraint
357357

358358
model._meta.unique_together += tuple(add_unique_together()) # type: ignore[operator]
359-
model._meta.constraints += tuple(add_constraints())
359+
model._meta.constraints += tuple(add_constraints()) # type: ignore[operator]
360360
# `unique_together` needs `original_attrs` to be set, for this changes to appear in migrations.
361361
for attr_name in ("unique_together",):
362362
if value := getattr(model._meta, attr_name):

0 commit comments

Comments
 (0)