Skip to content

Commit

Permalink
chore: ruff fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Oct 8, 2024
1 parent a0600fa commit 5845f9c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion mknodes/basenodes/mknode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def __hash__(self):
return hash(self.to_markdown())

def __eq__(self, other):
if not type(other) == type(self):
if not type(other) is type(self):
return False
dct_1 = self.__dict__.copy()
dct_2 = other.__dict__.copy()
Expand Down
6 changes: 3 additions & 3 deletions mknodes/basenodes/mktimeline/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import tomllib

from typing import Any, Literal
from xml.etree import ElementTree as Et
from xml.etree import ElementTree as ET

from mknodes.basenodes import mkcontainer, mknode
from mknodes.utils import log, pathhelpers, resources, xmlhelpers as xml
Expand Down Expand Up @@ -44,7 +44,7 @@ class MkTimelineItem(mknode.MkNode):
def __init__(
self,
title: str = "",
content: str | mknode.MkNode | Et.Element = "",
content: str | mknode.MkNode | ET.Element = "",
*,
label: str = "",
link: str = "",
Expand Down Expand Up @@ -97,7 +97,7 @@ def get_element(self) -> xml.Div:
if self.label:
xml.Div("date", text=self.label, parent=content_div)
text = f"<p>\n{self.content.to_html()}\n</p>"
content_div.append(Et.fromstring(text))
content_div.append(ET.fromstring(text))
if self.link:
xml.A("bnt-more", href=self.link, text=self.button_text, parent=content_div)
return root
Expand Down
2 changes: 1 addition & 1 deletion mknodes/templatenodes/mkpipdeptree/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Any, Literal

from mknodes.basenodes import mkdiagram
from mknodes.utils import helpers, log, packagehelpers, resources
from mknodes.utils import helpers, log, resources


logger = log.get_logger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion mknodes/utils/reprhelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def get_repr(
parts = [list_repr(v) if isinstance(v, list) else my_repr(v) for v in args]
kw_parts = []
for k, v in kwargs.items():
if _filter_empty and (v is None or v == "" or v == {}):
if _filter_empty and (v is None or v in ("", {})):
continue
if _filter_false and v is False:
continue
Expand Down
18 changes: 9 additions & 9 deletions mknodes/utils/xmlhelpers.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
from __future__ import annotations

from typing import Any
from xml.etree import ElementTree as Et
from xml.etree import ElementTree as ET

from mknodes.utils import icons, log


logger = log.get_logger(__name__)


class HTMLElement(Et.Element):
class HTMLElement(ET.Element):
tag_name: str

def __init__(
self,
klass: str | None = None,
parent: Et.Element | None = None,
parent: ET.Element | None = None,
*,
attrs: dict | None = None,
markdown: bool = False,
Expand Down Expand Up @@ -46,8 +46,8 @@ def __init__(
break

def to_string(self, space: str = " ", level: int = 0) -> str:
Et.indent(self, space=space, level=level)
return Et.tostring(self, encoding="unicode", method="html")
ET.indent(self, space=space, level=level)
return ET.tostring(self, encoding="unicode", method="html")


class Div(HTMLElement):
Expand All @@ -57,7 +57,7 @@ def __init__(
self,
klass: str | None = None,
text: str | None = None,
parent: Et.Element | None = None,
parent: ET.Element | None = None,
**kwargs: Any,
):
super().__init__(klass, parent, **kwargs)
Expand All @@ -69,7 +69,7 @@ def __init__(
self,
level: int,
text: str,
parent: Et.Element | None = None,
parent: ET.Element | None = None,
**kwargs: Any,
):
self.tag_name = f"h{level}"
Expand All @@ -94,7 +94,7 @@ def __init__(
self,
klass: str | None = None,
text: str | None = None,
parent: Et.Element | None = None,
parent: ET.Element | None = None,
**kwargs: Any,
):
super().__init__(klass, parent, **kwargs)
Expand Down Expand Up @@ -152,7 +152,7 @@ def __init__(
self,
klass: str | None = None,
text: str | None = None,
parent: Et.Element | None = None,
parent: ET.Element | None = None,
**kwargs: Any,
):
super().__init__(klass, parent, **kwargs)
Expand Down

0 comments on commit 5845f9c

Please sign in to comment.