Hello, I am a complete beginner when it comes to type hints, and I am currently trying to add them to my forms. What should I do with this code:
from typing import Type from django import forms from django.contrib.auth.forms import UserCreationForm from .models import User class CustomUserCreationForm(UserCreationForm): first_name = forms.CharField(max_length=50, required=False) last_name = forms.CharField(max_length=50, required=False) class Meta: model: Type[User] = User fields: tuple[str] = ('username', 'password1', 'password2', 'first_name', 'last_name', 'email')
I am currently getting two errors from mypy:
accounts/forms.py:9: error: Missing type parameters for generic type "UserCreationForm" [type-arg] accounts/forms.py:15: error: Incompatible types in assignment (expression has type "tuple[str, str, str, str, str, str]", variable has type "tuple[str]") [assignment]
I don't think it would be a good idea to pass the exact number of fields and I am also confused about how to define the type for the subclass (and should I even be doing it..). Thank you for any help!