mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 12:44:28 +08:00
Improve typing for BS4 element.Tag's get and get_attribute_list. (#12840)
This commit is contained in:
@@ -27,6 +27,7 @@ class ContentMetaAttributeValue(AttributeValueWithCharsetSubstitution):
|
||||
def __new__(cls, original_value): ...
|
||||
def encode(self, encoding: str) -> str: ... # type: ignore[override] # incompatible with str
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_PageElementT = TypeVar("_PageElementT", bound=PageElement)
|
||||
_SimpleStrainable: TypeAlias = str | bool | None | bytes | Pattern[str] | Callable[[str], bool] | Callable[[Tag], bool]
|
||||
_Strainable: TypeAlias = _SimpleStrainable | Iterable[_SimpleStrainable]
|
||||
@@ -276,8 +277,16 @@ class Tag(PageElement):
|
||||
def clear(self, decompose: bool = False) -> None: ...
|
||||
def smooth(self) -> None: ...
|
||||
def index(self, element: PageElement) -> int: ...
|
||||
def get(self, key: str, default: str | list[str] | None = None) -> str | list[str] | None: ...
|
||||
def get_attribute_list(self, key: str, default: str | list[str] | None = None) -> list[str]: ...
|
||||
@overload
|
||||
def get(self, key: str, default: None = None) -> str | list[str] | None: ...
|
||||
@overload
|
||||
def get(self, key: str, default: _T) -> str | list[str] | _T: ...
|
||||
@overload
|
||||
def get_attribute_list(self, key: str, default: None = None) -> list[str | None]: ...
|
||||
@overload
|
||||
def get_attribute_list(self, key: str, default: list[_T]) -> list[str | _T]: ...
|
||||
@overload
|
||||
def get_attribute_list(self, key: str, default: _T) -> list[str | _T]: ...
|
||||
def has_attr(self, key: str) -> bool: ...
|
||||
def __hash__(self) -> int: ...
|
||||
def __getitem__(self, key: str) -> str | list[str]: ...
|
||||
|
||||
Reference in New Issue
Block a user