Skip to content

Commit fea7de9

Browse files
committed
mypy: Don't use lazy ManyToManyField with implicit app label
In newer mypy[1][2], `ManyToManyField`s with lazy (string) models but no app label don't work. For the `to` model, we can just use `Person` directly (and do on the line above), so do that. For the `through` model, add the app label -- Django doesn't care, and it makes mypy happy. Also, in mypy, well-structured wildcard patterns match without a submodule too, so simplify some config. [1] typeddjango/django-stubs#1802 (comment), [2] typeddjango/django-stubs#1719 (comment) [3] https://mypy.readthedocs.io/en/stable/config_file.html#config-file-format
1 parent 58f3f86 commit fea7de9

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

mypy.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ ignore_missing_imports = True
99
[mypy-social_core.*]
1010
ignore_missing_imports = True
1111

12-
[mypy-social_django,social_django.*]
12+
[mypy-social_django.*]
1313
ignore_missing_imports = True

squaresdb/membership/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,9 @@ class TSClass(models.Model):
235235
label = models.CharField(max_length=20)
236236
coordinator = models.ForeignKey(Person, on_delete=models.PROTECT,
237237
related_name='class_coord')
238-
assistants = models.ManyToManyField('Person', through='TSClassAssist',
238+
assistants = models.ManyToManyField(Person, through='membership.TSClassAssist',
239239
related_name='class_assist')
240-
students = models.ManyToManyField('Person', through='TSClassMember',
240+
students = models.ManyToManyField(Person, through='membership.TSClassMember',
241241
related_name='classes')
242242
start_date = models.DateField(null=True, blank=True)
243243
end_date = models.DateField(null=True, blank=True)

0 commit comments

Comments
 (0)