django-stubs
django-stubs copied to clipboard
PEP-484 stubs for Django
# Bug report ## What's wrong Manually defining a field in `forms.ModelForm`: ```python class SpotForm(forms.ModelForm): files = forms.ImageField( widget=forms.ClearableFileInput(attrs={"multiple": True}), ) ``` causes this error: ``` error: Incompatible types in...
# Bug report ## What's wrong When defining a custom `QuerySet` with methods that return the `QuerySet`, `self` and the return type should both be a `TypeVar` so that if...
# Bug report ## What's wrong When the argument to `models.Manager.from_queryset()` is a type alias, the following `AssertionError` is raised: ``` version: 0.942 Traceback (most recent call last): File "mypy/semanal.py",...
# Bug report ## What's wrong Changes to typing of `core.handlers.WSGIHandler` introduced in #909 are incompatible with the stdlib annotations under `wsgiref`, raising a error when checked with mypy: ```python...
# Bug report ## What's wrong The async interface for BaseCache was added in 4.0, not 4.1. This is now causing mypy errors for 4.0.5 saying aget / aset does...
When writing data migrations, you use `apps.get_model()` instead of the usual model imports. However, PyCharm doesn't understand that the returned values are models: The problem is that `get_model` is set...
# Bug report MyPy seems to fail with a recursion error when `WithAnnotations` is used with a generic type variable as an argument. Here is a small example: ```python from...
# Bug report ## What's wrong I can't set the correct type on the return value of a values list. Simplified example: ``` models.py class Question: category = models.TextField() ```...
# Bug report ## What's wrong First, let's establish that annotation chaining with non-custom querysets methods works: ```py queryset = HostingAdvert.objects.annotate(is_cool=Value(True)).annotate(is_amazing=Value(False)) reveal_type(queryset) # Revealed type is "HostingAdvertQuerySet[WithAnnotations[HostingAdvert, TypedDict({'is_cool': Any, 'is_amazing':...
# Bug report ## What's wrong Even though a queryset is correctly typed with `WithAnnotations`, this annotation is lost when accessing an instance in the queryset, which means we can't...