Skip to content

Conversation

UnknownPlatypus
Copy link
Contributor

I have made things!

Implement generic type for the Sitemap class and also add the get_latest_lastmod method stub (added in django 4.1)

Related issues

from django.urls import reverse
from myapp.models import Offer

class OfferSitemap(Sitemap):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean

Suggested change
class OfferSitemap(Sitemap):
class OfferSitemap(Sitemap[Offer]):

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you're right. I just updated this and the other test.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need a case with

class WrongOfferSitemap(Sitemap[Offer]):
     def items() -> BadReturn: ...
     def locations(arg: BadArg): ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, I've added this

},
)

class WrongOfferSitemap(Sitemap[Offer]):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last question: what about GenericSiteMap? Should we test it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I was unsure about this one. I don't know how people are generally using it.

Maybe I should add a case close to the documentation exemple to make sure everything pass ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and one more for an incorrect version

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@sobolevn sobolevn merged commit 71b06f5 into typeddjango:master Oct 22, 2022
@UnknownPlatypus
Copy link
Contributor Author

Thanks for the review 🙌 !

@UnknownPlatypus UnknownPlatypus deleted the generic_sitemap branch October 22, 2022 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Sitemap type anotation is too restrictive The type for location in the class Sitemap is wrong.
2 participants