GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — PEP 695 alias with `WithAnnotations` leaks its row type into unrelated `QuerySet` annotations · Issue #3424 · typeddjango/django-stubs Closed Labels bugSomething isn't working DescriptionBug reportMay be it related to #3423 A PEP 695 type alias containing What's wrongThe annotated project type is incorrectly used as the row type of other querysets. Reproduction File structure:
SECRET_KEY = "repro" INSTALLED_APPS = ["repro"]
from django.db import models class Project(models.Model): name = models.CharField(max_length=100) class User(models.Model): name = models.CharField(max_length=100)
from typing import TypedDict from django.db import models from django_stubs_ext import WithAnnotations from repro.models import Project class ProjectAnnotations(TypedDict): occupied: int type ProjectQuerySet = models.QuerySet[ WithAnnotations[Project, ProjectAnnotations] ] class ProjectRepository: def get_projects(self) -> ProjectQuerySet: return Project.objects.annotate(occupied=models.Count("id"))
from django.db import models from repro.models import User class UserRepository: def get_users(self) -> models.QuerySet[User]: return User.objects.all()
from repro.repository.project import ProjectRepository as ProjectRepository from repro.repository.user import UserRepository as UserRepository
[mypy] plugins = mypy_django_plugin.main strict = true [mypy.plugins.django-stubs] django_settings_module = repro.settings Run: mypy --no-incremental --config-file mypy.ini repro/repository/user.py Actual behaviorThe function is annotated as How is that should be
The System information
Activity
MetadataMetadataAssigneesLabelsbugSomething isn't working TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |