Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
tabatkins committed Nov 15, 2023
1 parent 05105b2 commit fd8b219
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
21 changes: 13 additions & 8 deletions bikeshed/h/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]):
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
)


Expand Down
6 changes: 3 additions & 3 deletions bikeshed/t.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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,
Expand Down

0 comments on commit fd8b219

Please sign in to comment.