Skip to content

Commit

Permalink
Fix wrong type hints for SyndicationFeed methods
Browse files Browse the repository at this point in the history
Django's documentation mentions that the handles is of type
xml.sax.saxutils.XMLGenerator. However, it is actually of type
django.utils.xmlutils.SimplerXMLGenerator, which is a subclass of the
former.

Methods like `addQuickElement` (which are used in django's own
implementation of add_root_elements) is actually defined for
SimplerXMLGenerator, so this seems like the best fit (since subclasses
will generally rely on this method).
  • Loading branch information
WhyNotHugo committed Sep 12, 2023
1 parent 5f57a42 commit 6158969
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions django-stubs/utils/feedgenerator.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import datetime
from typing import Any
from xml.sax import ContentHandler
from django.utils.xmlutils import SimplerXMLGenerator

from typing_extensions import TypeAlias

Expand Down Expand Up @@ -49,9 +50,13 @@ class SyndicationFeed:
) -> None: ...
def num_items(self) -> int: ...
def root_attributes(self) -> dict[Any, Any]: ...
def add_root_elements(self, handler: ContentHandler) -> None: ...
def add_root_elements(self, handler: SimplerXMLGenerator) -> None: ...
def item_attributes(self, item: dict[str, Any]) -> dict[Any, Any]: ...
def add_item_elements(self, handler: ContentHandler, item: dict[str, Any]) -> None: ...
def add_item_elements(
self,
handler: SimplerXMLGenerator,
item: dict[str, Any],
) -> None: ...
def write(self, outfile: Any, encoding: Any) -> None: ...
def writeString(self, encoding: str) -> str: ...
def latest_post_date(self) -> datetime.datetime: ...
Expand Down

0 comments on commit 6158969

Please sign in to comment.