-
-
Notifications
You must be signed in to change notification settings - Fork 505
Closed
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomersstubsIssues in stubs files (.pyi)Issues in stubs files (.pyi)
Description
Bug report
What's wrong
The TemplateCommand
class stub (django-stubs/core/management/templates.pyi
) defines the handle
command as follows:
def handle(self, app_or_project: str, name: str, target: str | None = ..., **options: Any) -> None: ...
We can see that in subclasses (startapp and startproject), Django actually does not follow the super's definition, instead manually parsing kwargs to pass into the super's method:
# django.core.management.commands.startapp
class Command(TemplateCommand):
help = (
"Creates a Django app directory structure for the given app name in "
"the current directory or optionally in the given directory."
)
missing_args_message = "You must provide an application name."
def handle(self, **options):
app_name = options.pop("name")
target = options.pop("directory")
super().handle("app", app_name, target, **options)
How is that should be
This is an issue where Django itself is kinda violating the principles of inheritance by havind a different definition in the child class; however, I believe the stubs should still reflect this behaviour, and should define the class methods for the respective commands in the way they are actually used:
def handle(self, **options: Any) -> Optional[str]: ...
System information
- OS:
python
version: 3.11django
version: 4.2.7mypy
version: 1.6.1django-stubs
version: 4.2.6django-stubs-ext
version: 4.2.5
intgr
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomersstubsIssues in stubs files (.pyi)Issues in stubs files (.pyi)