From 864dee36fbe97785d66225f9446c654622248748 Mon Sep 17 00:00:00 2001 From: Kanishk Pachauri Date: Fri, 10 May 2024 14:15:44 +0530 Subject: [PATCH] stubs: [BeautifulSoup] fix incomplete type specs for formatter (#11885) --- stubs/beautifulsoup4/bs4/element.pyi | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/stubs/beautifulsoup4/bs4/element.pyi b/stubs/beautifulsoup4/bs4/element.pyi index c0452c628..6e9cf6d5f 100644 --- a/stubs/beautifulsoup4/bs4/element.pyi +++ b/stubs/beautifulsoup4/bs4/element.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete, ReadableBuffer from collections.abc import Callable, Iterable, Iterator from re import Pattern -from typing import Any, TypeVar, overload +from typing import Any, Literal, TypeVar, overload from typing_extensions import Self, TypeAlias from . import BeautifulSoup @@ -295,25 +295,33 @@ class Tag(PageElement): self, encoding: str = "utf-8", indent_level: int | None = None, - formatter: str | Formatter = "minimal", + formatter: Literal["html", "html5", "minimal"] | Formatter | None = "minimal", errors: str = "xmlcharrefreplace", ) -> bytes: ... def decode( self, indent_level: int | None = None, eventual_encoding: str = "utf-8", - formatter: str | Formatter = "minimal", + formatter: Literal["html", "html5", "minimal"] | Formatter | None = "minimal", iterator: Iterator[PageElement] | None = None, ) -> str: ... @overload - def prettify(self, encoding: str, formatter: str | Formatter = "minimal") -> bytes: ... + def prettify(self, encoding: str, formatter: Literal["html", "html5", "minimal"] | Formatter | None = "minimal") -> bytes: ... @overload - def prettify(self, encoding: None = None, formatter: str | Formatter = "minimal") -> str: ... + def prettify( + self, encoding: None = None, formatter: Literal["html", "html5", "minimal"] | Formatter | None = "minimal" + ) -> str: ... def decode_contents( - self, indent_level: int | None = None, eventual_encoding: str = "utf-8", formatter: str | Formatter = "minimal" + self, + indent_level: int | None = None, + eventual_encoding: str = "utf-8", + formatter: Literal["html", "html5", "minimal"] | Formatter | None = "minimal", ) -> str: ... def encode_contents( - self, indent_level: int | None = None, encoding: str = "utf-8", formatter: str | Formatter = "minimal" + self, + indent_level: int | None = None, + encoding: str = "utf-8", + formatter: Literal["html", "html5", "minimal"] | Formatter | None = "minimal", ) -> bytes: ... def renderContents(self, encoding: str = "utf-8", prettyPrint: bool = False, indentLevel: int = 0) -> bytes: ... def find(