From fd8b2199771689c3faa26c21ceff4b00e0ad7c39 Mon Sep 17 00:00:00 2001 From: Tab Atkins-Bittner Date: Wed, 15 Nov 2023 12:54:47 -0800 Subject: [PATCH] lint --- bikeshed/h/parser.py | 21 +++++++++++++-------- bikeshed/t.py | 6 +++--- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/bikeshed/h/parser.py b/bikeshed/h/parser.py index c1f6982682..2550be69cb 100644 --- a/bikeshed/h/parser.py +++ b/bikeshed/h/parser.py @@ -387,7 +387,8 @@ def __str__(self) -> str: return f"{self.s.loc(self.index)} {self.details}" -ResultT = t.TypeVar('ResultT') +ResultT = t.TypeVar("ResultT") + @dataclass class Result(t.Generic[ResultT]): @@ -554,7 +555,11 @@ def __str__(self) -> str: return self.text def curlifyApostrophes(self, lastNode: ParserNode | None) -> Text: - if self.text[0] == "'" and isinstance(lastNode, (EndTag, RawElement, SelfClosedTag)) and re.match(r"'\w", self.text): + if ( + self.text[0] == "'" + and isinstance(lastNode, (EndTag, RawElement, SelfClosedTag)) + and re.match(r"'\w", self.text) + ): self.text = "’" + self.text[1:] if "'" in self.text: self.text = re.sub(r"(\w)'(\w)", r"\1’\2", self.text) @@ -626,13 +631,13 @@ def clone(self, **kwargs: t.Any) -> SelfClosedTag: return dataclasses.replace(self, **kwargs) @classmethod - def fromStartTag(cls, tag: StartTag) -> SelfClosedTag: + def fromStartTag(cls: t.Type[SelfClosedTag], tag: StartTag) -> SelfClosedTag: return cls( - line = tag.line, - endLine = tag.endLine, - tag = tag.tag, - attrs = tag.attrs, - classes = tag.classes, + line=tag.line, + endLine=tag.endLine, + tag=tag.tag, + attrs=tag.attrs, + classes=tag.classes, ) diff --git a/bikeshed/t.py b/bikeshed/t.py index 1ccd9b6dc5..5f1cd505d1 100644 --- a/bikeshed/t.py +++ b/bikeshed/t.py @@ -3,9 +3,8 @@ from __future__ import annotations # The only three things that should be available during runtime. -from typing import TYPE_CHECKING, cast, overload # ...except I need these too, to declare a generic class. -from typing import Generic, TypeVar +from typing import TYPE_CHECKING, Generic, TypeVar, cast, overload if TYPE_CHECKING: from typing import ( @@ -29,12 +28,13 @@ Protocol, Sequence, TextIO, + Type, TypeAlias, TypedDict, TypeGuard, ) - from _typeshed import SupportsKeysAndGetItem, Self + from _typeshed import Self, SupportsKeysAndGetItem from lxml import etree from typing_extensions import ( NotRequired,