Use typing_extensions.Self instead of _typeshed.Self (#9702)

This commit is contained in:
Alex Waygood
2023-02-15 11:32:43 +01:00
committed by GitHub
parent 8cd6d81f15
commit 7180d0223b
140 changed files with 597 additions and 610 deletions
+3 -2
View File
@@ -1,6 +1,7 @@
from _typeshed import Incomplete, Self, SupportsRead
from _typeshed import Incomplete, SupportsRead
from collections.abc import Sequence
from typing import Any
from typing_extensions import Self
from .builder import ParserRejectedMarkup as ParserRejectedMarkup, TreeBuilder, XMLParsedAsHTMLWarning as XMLParsedAsHTMLWarning
from .element import (
@@ -45,7 +46,7 @@ class BeautifulSoup(Tag):
element_classes: dict[type[PageElement], type[Any]] | None = ...,
**kwargs,
) -> None: ...
def __copy__(self: Self) -> Self: ...
def __copy__(self) -> Self: ...
hidden: bool
current_data: Any
currentTag: Any
+9 -9
View File
@@ -1,8 +1,8 @@
from _typeshed import Incomplete, Self
from _typeshed import Incomplete
from collections.abc import Callable, Iterable, Iterator
from re import Pattern
from typing import Any, Generic, TypeVar, overload
from typing_extensions import TypeAlias
from typing_extensions import Self, TypeAlias
from . import BeautifulSoup
from .builder import TreeBuilder
@@ -14,7 +14,7 @@ whitespace_re: Pattern[str]
PYTHON_SPECIFIC_ENCODINGS: set[str]
class NamespacedAttribute(str):
def __new__(cls: type[Self], prefix: str, name: str | None = ..., namespace: str | None = ...) -> Self: ...
def __new__(cls, prefix: str, name: str | None = ..., namespace: str | None = ...) -> Self: ...
class AttributeValueWithCharsetSubstitution(str): ...
@@ -57,13 +57,13 @@ class PageElement:
getText = get_text
@property
def text(self) -> str: ...
def replace_with(self: Self, *args: PageElement | str) -> Self: ...
def replace_with(self, *args: PageElement | str) -> Self: ...
replaceWith = replace_with
def unwrap(self: Self) -> Self: ...
def unwrap(self) -> Self: ...
replace_with_children = unwrap
replaceWithChildren = unwrap
def wrap(self, wrap_inside: _PageElementT) -> _PageElementT: ...
def extract(self: Self, _self_index: int | None = ...) -> Self: ...
def extract(self, _self_index: int | None = ...) -> Self: ...
def insert(self, position: int, new_child: PageElement | str) -> None: ...
def append(self, tag: PageElement | str) -> None: ...
def extend(self, tags: Iterable[PageElement | str]) -> None: ...
@@ -182,8 +182,8 @@ class NavigableString(str, PageElement):
PREFIX: str
SUFFIX: str
known_xml: bool | None
def __new__(cls: type[Self], value: str | bytes) -> Self: ...
def __copy__(self: Self) -> Self: ...
def __new__(cls, value: str | bytes) -> Self: ...
def __copy__(self) -> Self: ...
def __getnewargs__(self) -> tuple[str]: ...
def output_ready(self, formatter: Formatter | str | None = ...) -> str: ...
@property
@@ -260,7 +260,7 @@ class Tag(PageElement):
namespaces: dict[str, str] | None = ...,
) -> None: ...
parserClass: type[BeautifulSoup] | None
def __copy__(self: Self) -> Self: ...
def __copy__(self) -> Self: ...
@property
def is_empty_element(self) -> bool: ...
@property