-
-
Notifications
You must be signed in to change notification settings - Fork 553
Description
Description:
Running ./scripts/stubtest.sh on the current version of django-stubs reveals several inconsistencies between the stubs and the runtime environment.
- Choices Classes Inconsistency (
__init__vs__new__)
Multiple errors indicate that IntegerChoices and TextChoices define __init__ with parameters in the stubs, but at runtime, these parameters do not exist in __init__. The error message suggests moving the logic to __new__.
Affected modules:
-
django.db.models.enums -
django.contrib.gis.db.models -
django.tasks.base
Example Error:
error: django.db.models.enums.IntegerChoices.__init__ is inconsistent, runtime does not have parameter "x".
You may need to write stubs for __new__ instead of __init__.
Stub: Overload(def (self: ..., x: ...), def (self: ..., x: ..., label: ...))
Runtime: def (self)
- Missing members in
django.utils.inspect
The runtime has lock and safe_signature_from_callable which are completely missing from the stubs.
Errors:
error: django.utils.inspect.lock is not present in stub
error: django.utils.inspect.safe_signature_from_callable is not present in stub
Environment:
Django version: [Write your Django version here, e.g., 5.0]
Python version: [Write your Python version here, e.g., 3.12]
Command run: `./scripts/stubtest.sh`
Question:
Is this expected behavior for the current state of the stubs, or should these be addressed by moving the signatures to __new__ and adding the missing members to django.utils.inspect?