-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
In django-stubs we are using common.add_method to add some methods that are generated in runtime for some django fields. For example, DateField generates get_next_by_FIELD_NAME.
Source: https://github.com/django/django/blob/72b7aecbbfbec0ceb1a829eef82a68d7283df604/django/db/models/fields/__init__.py#L1515-L1531
Plugin: https://github.com/typeddjango/django-stubs/blob/23530b96dd17efa1eb9961c86894fb734658ee0d/mypy_django_plugin/transformers/models.py#L591-L621
So, when there are several mixins that both provide the same method (django models use mixins quite often), then there are very annoying false-positives:
server/apps/identity/models.py:57: error: Method "get_next_by_created_at" is not using @override but is overriding a method in class "server.common.django.models.TimedMixin" [explicit-override]
server/apps/identity/models.py:57: error: Method "get_previous_by_created_at" is not using @override but is overriding a method in class "server.common.django.models.TimedMixin" [explicit-override]
server/apps/identity/models.py:57: error: Method "get_next_by_updated_at" is not using @override but is overriding a method in class "server.common.django.models.TimedMixin" [explicit-override]
server/apps/identity/models.py:57: error: Method "get_previous_by_updated_at" is not using @override but is overriding a method in class "server.common.django.models.TimedMixin" [explicit-override]It took me quite some time to understand what is going on there.
I propose to add a new flag to common.add_method, which will set explicit_override by default.