Skip to content

Commit 0e92bbd

Browse files
authored
use ruff (#5)
* wip * add ruff * update deps
1 parent 0223d6a commit 0e92bbd

9 files changed

Lines changed: 115 additions & 212 deletions

File tree

bench/dom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55

66
def hello_world_empty(objs: List[None]) -> None:
77
for _ in objs:
8-
h1("Hello, World!").render()
8+
h1("Hello, World!").render()

bench/fast.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55

66
def hello_world_empty(objs: List[None]) -> None:
77
for _ in objs:
8-
render(h1("Hello, World!"))
8+
render(h1("Hello, World!"))

bench/run.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,19 @@ class BenchCompare(Generic[A]):
2222
benches: Dict[str, BenchCompare[Any]] = {
2323
"hello world": BenchCompare(
2424
lambda i: None,
25-
{JINJA2: jin.hello_world_empty,
26-
FAST_HTML: fast.hello_world_empty,
27-
DOMINATE: dom.hello_world_empty,
28-
SIMPLE_HTML: simple.hello_world_empty,
29-
},
25+
{
26+
JINJA2: jin.hello_world_empty,
27+
FAST_HTML: fast.hello_world_empty,
28+
DOMINATE: dom.hello_world_empty,
29+
SIMPLE_HTML: simple.hello_world_empty,
30+
},
3031
),
3132
"basic": BenchCompare(
3233
lambda i: (str(i), f"some content {i}", ["ok" for _ in range(i % 50)]),
33-
{SIMPLE_HTML: simple.basic,
34-
JINJA2: jin.basic,
35-
},
34+
{
35+
SIMPLE_HTML: simple.basic,
36+
JINJA2: jin.basic,
37+
},
3638
),
3739
"lorem ipsum": BenchCompare(
3840
lambda i: f"title {i}",

bench/simple.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
li,
1313
safe_string,
1414
br,
15-
meta, DOCTYPE_HTML5,
15+
meta,
16+
DOCTYPE_HTML5,
1617
)
1718
from simple_html.render import render
1819

@@ -44,7 +45,7 @@ def basic(objs: List[Tuple[str, str, List[str]]]) -> None:
4445
),
4546
),
4647
),
47-
)
48+
),
4849
)
4950

5051

@@ -118,7 +119,7 @@ def basic_long(objs: List[Tuple[str, str, List[str]]]) -> None:
118119
),
119120
),
120121
),
121-
)
122+
),
122123
)
123124

124125

poetry.lock

Lines changed: 83 additions & 181 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@ python = "^3.8.1"
1414

1515
[tool.poetry.group.dev.dependencies]
1616
jinja2 = "3.1.2"
17-
flake8 = "6.1.0"
18-
mypy = "1.6.0"
19-
pytest = "7.4.2"
20-
setuptools = "68.2.2"
21-
black = "23.9.1"
22-
django = "^4.2.6"
23-
fast-html = "^1.0.3"
24-
dominate = "^2.8.0"
17+
mypy = "1.7.0"
18+
pytest = "7.4.3"
19+
setuptools = "69.0.0"
20+
django = "4.2.7"
21+
fast-html = "1.0.4"
22+
dominate = "2.9.0"
23+
ruff = "0.1.6"
2524

2625

2726
[build-system]
@@ -41,7 +40,7 @@ disallow_untyped_calls = true
4140
disallow_untyped_decorators = true
4241
disallow_untyped_defs = true
4342
ignore_errors = false
44-
ignore_missing_imports = false
43+
ignore_missing_imports = true
4544
local_partial_types = true
4645
no_implicit_optional = true
4746
no_implicit_reexport = true

setup.cfg

Lines changed: 0 additions & 3 deletions
This file was deleted.

simple_html/nodes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def safe_string(x: str) -> SafeString:
2020

2121

2222
class Tag:
23-
__slots__ = ('tag_start', 'rendered', "closing_tag", "no_children_close")
23+
__slots__ = ("tag_start", "rendered", "closing_tag", "no_children_close")
2424

2525
def __init__(self, name: str, self_closing: bool = False) -> None:
2626
self.tag_start = f"<{name}"
@@ -33,18 +33,18 @@ def __init__(self, name: str, self_closing: bool = False) -> None:
3333
self.rendered = f"{self.tag_start}{self.no_children_close}"
3434

3535
def __call__(
36-
self, attributes: Dict[str, Optional[str]], *children: Node
36+
self, attributes: Dict[str, Optional[str]], *children: Node
3737
) -> Union[TagTuple, SafeString]:
3838
if attributes:
3939
# in this case this is faster than attrs = "".join([...])
4040
attrs = ""
4141
for key, val in attributes.items():
42-
attrs += (" " + key if val is None else f' {key}="{val}"')
42+
attrs += " " + key if val is None else f' {key}="{val}"'
4343

4444
if children:
4545
return f"{self.tag_start}{attrs}>", children, self.closing_tag
4646
else:
47-
return f"{self.tag_start}{attrs}{self.no_children_close}",
47+
return (f"{self.tag_start}{attrs}{self.no_children_close}",)
4848
return f"{self.tag_start}>", children, self.closing_tag
4949

5050

tests/test_render.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
p,
1717
script,
1818
span,
19-
Node, DOCTYPE_HTML5,
19+
Node,
20+
DOCTYPE_HTML5,
2021
)
2122
from simple_html.render import render
2223

@@ -73,7 +74,8 @@ def test_safe_strings_are_not_escaped() -> None:
7374
def test_simple_form() -> None:
7475
node = form(
7576
{"method": "POST", "enctype": "multipart/form-data"},
76-
label({},
77+
label(
78+
{},
7779
"Name",
7880
input_(
7981
{"type": "text", "value": "some_value", "placeholder": "example text"}

0 commit comments

Comments
 (0)