Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyCharm type hint bug. #2516

Open
changja88 opened this issue Feb 20, 2025 · 2 comments
Open

PyCharm type hint bug. #2516

changja88 opened this issue Feb 20, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@changja88
Copy link

story_models: QuerySet[StoryModel] = StoryModel.objects.filter(
    member_id=owner_member_id,
    created__gte=dtz.now() - timedelta(days=1),
    is_deleted=False,
).order_by("-created")



class StoryModel(TimeStampedModel):
    member = models.ForeignKey(
        MemberModel, on_delete=models.CASCADE, related_name="member_story", help_text="스토리 주인 멤버"
    )
    file = ResizedImageField(quality=80, upload_to=get_s3_file_path_for_story)
    is_show = models.BooleanField(default=True, help_text="스토리 공개 여부")

PyCharm says "Expected QuerySet[StoryModel, StoryModel] but got QuerySet[StoryModel].

story_models: list[StoryModel] = StoryModel.objects.filter(
    member_id=owner_member_id,
    created__gte=dtz.now() - timedelta(days=1),
    is_deleted=False,
).order_by("-created")

If I change type hint to list from queryset, pycharms syas expected list[StoryMoel] but got QuerySet[StoryMoel]

Please help me fix this issues
Thanks a lot :)

System information

  • OS: MacOS
  • python version: 3.13.1
  • django version: 5.1.6
  • mypy version: mypy 1.15.0 (compiled: yes)
  • django-stubs version: django-stubs = { version = "^5.1.1", extras = ["compatible-mypy"] }
  • django-stubs-ext version: X
@changja88 changja88 added the bug Something isn't working label Feb 20, 2025
@sobolevn
Copy link
Member

sorry, I am not sure that pycharm has something to do with django-stubs.

@sobolevn
Copy link
Member

Please help me fix this issues

But, if you know what to do, please, go ahead!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants