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

Mypy Support For TaggableManager #902

Open
jmichalicek opened this issue Jul 4, 2024 · 2 comments
Open

Mypy Support For TaggableManager #902

jmichalicek opened this issue Jul 4, 2024 · 2 comments

Comments

@jmichalicek
Copy link

I have a model with a TaggableManager for a model with direct foreign keys defined, per the docs:

class TaggedRecipe(TaggedItemBase):
    content_object = models.ForeignKey("Recipe", on_delete=models.CASCADE)

    def __str__(self) -> str:
        return f"{self.content_object}: {self.tag}"

and then on the Recipe model:

tags = TaggableManager(through=TaggedRecipe)

When running mypy, I get an error about that line error: Couldn't resolve related manager for relation 'tagged_recipes' with the actual error being [django-manager-missing]

This is with the following versions:
Django 5.0.6
django-taggit 5.0.1
mypy 1.10.1
django-stubs 5.0.2
django-stubs-ext 5.0.2

@rtpg
Copy link
Contributor

rtpg commented Jul 5, 2024

I guess that's from the mypy django plugin? Will need to look at into if we can get it to play nicely with django-taggit. Thanks for the clear report!

@rtpg rtpg changed the title How to specify type definitions for mypy? Mypy Support For TaggableManager Jul 5, 2024
@pheki
Copy link

pheki commented Oct 1, 2024

This looks related to typeddjango/django-stubs#1023

From what I could gather, it seems like adding typing information to django-taggit could fix the issue, but I'm not sure.

That said, even if it didn't fix that specific issue, it would be nice to have django-taggit typed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants