Skip to content

Commit 23d3478

Browse files
committed
Black settings.
1 parent 985fb66 commit 23d3478

File tree

3 files changed

+13
-38
lines changed

3 files changed

+13
-38
lines changed

‎pyproject.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ format-jinja = """{%- if distance == 0 -%}
6161
{%- endif -%}"""
6262

6363
[tool.black]
64-
line-length = 88
64+
line-length = 100
6565

6666
[tool.ruff]
67-
line-length = 88
67+
line-length = 100
6868

6969
[tool.ruff.lint]
7070
ignore = ["E402", "E731", "E712"]

‎src/prettyfmt/prettyfmt.py‎

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,11 @@ def __str__(self) -> str:
136136
visited.add(id(value))
137137

138138
if isinstance(value, list):
139-
truncated_list = value[:list_max_len] + (
140-
["…"] if len(value) > list_max_len else []
141-
)
139+
truncated_list = value[:list_max_len] + (["…"] if len(value) > list_max_len else [])
142140
return (
143141
"["
144142
+ ", ".join(
145-
abbrev_obj(
146-
item, field_max_len, list_max_len, key_filter, value_filter, visited
147-
)
143+
abbrev_obj(item, field_max_len, list_max_len, key_filter, value_filter, visited)
148144
for item in truncated_list
149145
)
150146
+ "]"
@@ -161,11 +157,7 @@ def __str__(self) -> str:
161157
)
162158

163159
if isinstance(value, dict):
164-
return (
165-
"{"
166-
+ _format_kvs(value.items(), field_max_len, key_filter, value_filter)
167-
+ "}"
168-
)
160+
return "{" + _format_kvs(value.items(), field_max_len, key_filter, value_filter) + "}"
169161

170162
if isinstance(value, Enum):
171163
return value.name
@@ -190,10 +182,7 @@ def abbrev_on_words(text: str, max_len: int = 64, indicator: str = "…") -> str
190182
if words and max_len and len(words[0]) > max_len:
191183
return abbrev_str(words[0], max_len, indicator)
192184

193-
while (
194-
words
195-
and len(_trim_trailing_punctuation(" ".join(words))) + len(indicator) > max_len
196-
):
185+
while words and len(_trim_trailing_punctuation(" ".join(words))) + len(indicator) > max_len:
197186
words.pop()
198187

199188
return _trim_trailing_punctuation(" ".join(words)) + indicator
@@ -225,10 +214,7 @@ def abbrev_phrase_in_middle(
225214
# Walk through the split words, and tally total number of chars as we go.
226215
for i in range(len(words)):
227216
words[i] = abbrev_str(words[i], max_len, ellipsis)
228-
if (
229-
prefix_tally + len(words[i]) + len(ellipsis) + max_trailing_len >= max_len
230-
and i > 0
231-
):
217+
if prefix_tally + len(words[i]) + len(ellipsis) + max_trailing_len >= max_len and i > 0:
232218
prefix_end_index = i
233219
break
234220
prefix_tally += len(words[i]) + 1
@@ -290,9 +276,7 @@ def fmt_age(since_time: float | timedelta, brief: bool = False) -> str:
290276
suppress = []
291277
min_unit = "years"
292278

293-
age = precisedelta(
294-
seconds, minimum_unit=min_unit, suppress=suppress, format="%0.0f"
295-
)
279+
age = precisedelta(seconds, minimum_unit=min_unit, suppress=suppress, format="%0.0f")
296280
if brief:
297281
age = (
298282
age.replace(" seconds", "s")

‎tests/test_prettyfmt.py‎

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,12 @@ def test_abbreviate_on_words():
3131

3232

3333
def test_abbreviate_phrase_in_middle():
34+
assert abbrev_phrase_in_middle("Hello, World! This is a test.", 16) == "Hello, … a test."
3435
assert (
35-
abbrev_phrase_in_middle("Hello, World! This is a test.", 16)
36-
== "Hello, … a test."
36+
abbrev_phrase_in_middle("Hello, World! This is a test.", 23) == "Hello, … This is a test."
3737
)
3838
assert (
39-
abbrev_phrase_in_middle("Hello, World! This is a test.", 23)
40-
== "Hello, … This is a test."
41-
)
42-
assert (
43-
abbrev_phrase_in_middle("Hello, World! This is a test.", 27)
44-
== "Hello, … This is a test."
39+
abbrev_phrase_in_middle("Hello, World! This is a test.", 27) == "Hello, … This is a test."
4540
)
4641
assert (
4742
abbrev_phrase_in_middle("Hello, World! This is a test.", 40)
@@ -125,9 +120,7 @@ def test_sanitize_title() -> None:
125120
assert sanitize_title("Hej, Världen!") == "Hej, Världen!"
126121
assert sanitize_title("你好 世界") == "你好 世界"
127122
assert sanitize_title("こんにちは、世界") == "こんにちは 世界"
128-
assert (
129-
sanitize_title(" *Hello,* \n\tWorld! --123@:': ") == "Hello, World! --123@:':"
130-
)
123+
assert sanitize_title(" *Hello,* \n\tWorld! --123@:': ") == "Hello, World! --123@:':"
131124
assert sanitize_title("<script foo='blah'><p>") == "script foo 'blah' p"
132125

133126

@@ -158,7 +151,5 @@ def __str__(self) -> str:
158151
"This should be skipped.",
159152
)
160153
)
161-
expected = (
162-
"MyThing(title='Hello, World!', file_path=~/1234567…, url=https://example.com)"
163-
)
154+
expected = "MyThing(title='Hello, World!', file_path=~/1234567…, url=https://example.com)"
164155
assert s == expected

0 commit comments

Comments
 (0)