Use TypeAlias where possible for type aliases (#7630)

This commit is contained in:
Alex Waygood
2022-04-16 02:01:00 +01:00
committed by GitHub
parent c0e6dd3f3f
commit 740193a8fc
218 changed files with 760 additions and 625 deletions
+5 -4
View File
@@ -1,6 +1,7 @@
from _typeshed import Self
from collections.abc import Iterator
from typing import Any, Callable, Generic, Iterable, Pattern, TypeVar, overload
from typing_extensions import TypeAlias
from . import BeautifulSoup
from .builder import TreeBuilder
@@ -27,10 +28,10 @@ class ContentMetaAttributeValue(AttributeValueWithCharsetSubstitution):
def encode(self, encoding: str) -> str: ... # type: ignore[override] # incompatible with str
_PageElementT = TypeVar("_PageElementT", bound=PageElement)
_SimpleStrainable = str | bool | None | bytes | Pattern[str] | Callable[[str], bool] | Callable[[Tag], bool]
_Strainable = _SimpleStrainable | Iterable[_SimpleStrainable]
_SimpleNormalizedStrainable = str | bool | None | Pattern[str] | Callable[[str], bool] | Callable[[Tag], bool]
_NormalizedStrainable = _SimpleNormalizedStrainable | Iterable[_SimpleNormalizedStrainable]
_SimpleStrainable: TypeAlias = str | bool | None | bytes | Pattern[str] | Callable[[str], bool] | Callable[[Tag], bool]
_Strainable: TypeAlias = _SimpleStrainable | Iterable[_SimpleStrainable]
_SimpleNormalizedStrainable: TypeAlias = str | bool | None | Pattern[str] | Callable[[str], bool] | Callable[[Tag], bool]
_NormalizedStrainable: TypeAlias = _SimpleNormalizedStrainable | Iterable[_SimpleNormalizedStrainable]
class PageElement:
parent: Tag | None
+2 -1
View File
@@ -1,8 +1,9 @@
from typing import Callable
from typing_extensions import TypeAlias
from .dammit import EntitySubstitution as EntitySubstitution
_EntitySubstitution = Callable[[str], str]
_EntitySubstitution: TypeAlias = Callable[[str], str]
class Formatter(EntitySubstitution):
HTML: str