django-stubs icon indicating copy to clipboard operation
django-stubs copied to clipboard

The type for location in the class Sitemap is wrong.

Open adambirds opened this issue 3 years ago • 1 comments

https://github.com/typeddjango/django-stubs/blob/8d8b8cd1fc8b54eac799905dbbffc4e21708b6da/django-stubs/contrib/sitemaps/init.pyi#L24

The item shouldn't just be Model. As you can see it can also just be a string too if creating a sitemap of pages that aren't in models:

class StaticViewSitemap(Sitemap):
    priority = 1
    changefreq = "always"

    def items(self) -> List[str]:
        return ["home", "about", "contact", "recommendations", "privacy-policy", "blog"]

    def location(self, item: str) -> str:
        return reverse(item)

adambirds avatar Jun 17 '22 12:06 adambirds

I have temp got round this by just specifying it with Any but not ideal.

adambirds avatar Jun 17 '22 12:06 adambirds