Skip to content

stubtest: Inconsistencies in TextChoices, IntegerChoices and missing members in django.utils.inspect #3148

Open

Description

@ahmedasar00

Description:

Running ./scripts/stubtest.sh on the current version of django-stubs reveals several inconsistencies between the stubs and the runtime environment.

  1. 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)
  1. 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?

Activity

  1. ngnpope commented on Mar 2, 2026

    @ngnpope
    Member

    Yeah, this is a known issue with Python 3.14 - it's just that nobody has had a chance to properly look into this yet. Assistance is welcome.

  2. ngnpope commented on Mar 3, 2026

    @ngnpope
    Member

    ...adding the missing members to django.utils.inspect?

    This part was completed in #3152. I'll need some time to think about the enum issues.

  3. changed the title [-]stubtest: Inconsistencies in `TextChoices, `IntegerChoices` and missing members in `django.utils.inspect`[/-] [+]stubtest: Inconsistencies in `TextChoices`, `IntegerChoices` and missing members in `django.utils.inspect`[/+] on Mar 3, 2026
  4. ahmedasar00 commented on Mar 3, 2026

    @ahmedasar00
    ContributorAuthor

    This part was completed in #3152

    Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions