Skip to content

Commit 656506d

Browse files
Upgrade pyupgrade to 3.9
1 parent 30d44b9 commit 656506d

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ repos:
5050
rev: v3.19.0
5151
hooks:
5252
- id: pyupgrade
53-
args: [--py3-plus]
53+
args: [--py39-plus]
5454

5555
- repo: https://github.com/pre-commit/mirrors-eslint
5656
rev: v9.15.0

src/pytest_html/basereport.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def _process_report(self, report, duration, processed_extras):
306306

307307
def _format_duration(duration):
308308
if duration < 1:
309-
return "{} ms".format(round(duration * 1000))
309+
return f"{round(duration * 1000)} ms"
310310

311311
hours = math.floor(duration / 3600)
312312
remaining_seconds = duration % 3600

src/pytest_html/extras.py

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# This Source Code Form is subject to the terms of the Mozilla Public
22
# License, v. 2.0. If a copy of the MPL was not distributed with this
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4-
from typing import Dict
54
from typing import Optional
65

76
FORMAT_HTML = "html"
@@ -18,7 +17,7 @@ def extra(
1817
name: Optional[str] = None,
1918
mime_type: Optional[str] = None,
2019
extension: Optional[str] = None,
21-
) -> Dict[str, Optional[str]]:
20+
) -> dict[str, Optional[str]]:
2221
return {
2322
"name": name,
2423
"format_type": format_type,
@@ -28,7 +27,7 @@ def extra(
2827
}
2928

3029

31-
def html(content: str) -> Dict[str, Optional[str]]:
30+
def html(content: str) -> dict[str, Optional[str]]:
3231
return extra(content, FORMAT_HTML)
3332

3433

@@ -37,31 +36,31 @@ def image(
3736
name: str = "Image",
3837
mime_type: str = "image/png",
3938
extension: str = "png",
40-
) -> Dict[str, Optional[str]]:
39+
) -> dict[str, Optional[str]]:
4140
return extra(content, FORMAT_IMAGE, name, mime_type, extension)
4241

4342

44-
def png(content: str, name: str = "Image") -> Dict[str, Optional[str]]:
43+
def png(content: str, name: str = "Image") -> dict[str, Optional[str]]:
4544
return image(content, name, mime_type="image/png", extension="png")
4645

4746

48-
def jpg(content: str, name: str = "Image") -> Dict[str, Optional[str]]:
47+
def jpg(content: str, name: str = "Image") -> dict[str, Optional[str]]:
4948
return image(content, name, mime_type="image/jpeg", extension="jpg")
5049

5150

52-
def svg(content: str, name: str = "Image") -> Dict[str, Optional[str]]:
51+
def svg(content: str, name: str = "Image") -> dict[str, Optional[str]]:
5352
return image(content, name, mime_type="image/svg+xml", extension="svg")
5453

5554

56-
def json(content: str, name: str = "JSON") -> Dict[str, Optional[str]]:
55+
def json(content: str, name: str = "JSON") -> dict[str, Optional[str]]:
5756
return extra(content, FORMAT_JSON, name, "application/json", "json")
5857

5958

60-
def text(content: str, name: str = "Text") -> Dict[str, Optional[str]]:
59+
def text(content: str, name: str = "Text") -> dict[str, Optional[str]]:
6160
return extra(content, FORMAT_TEXT, name, "text/plain", "txt")
6261

6362

64-
def url(content: str, name: str = "URL") -> Dict[str, Optional[str]]:
63+
def url(content: str, name: str = "URL") -> dict[str, Optional[str]]:
6564
return extra(content, FORMAT_URL, name)
6665

6766

@@ -70,9 +69,9 @@ def video(
7069
name: str = "Video",
7170
mime_type: str = "video/mp4",
7271
extension: str = "mp4",
73-
) -> Dict[str, Optional[str]]:
72+
) -> dict[str, Optional[str]]:
7473
return extra(content, FORMAT_VIDEO, name, mime_type, extension)
7574

7675

77-
def mp4(content: str, name: str = "Video") -> Dict[str, Optional[str]]:
76+
def mp4(content: str, name: str = "Video") -> dict[str, Optional[str]]:
7877
return video(content, name)

testing/legacy_test_pytest_html.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def read_html(path):
2828

2929
def assert_results_by_outcome(html, test_outcome, test_outcome_number, label=None):
3030
# Asserts if the test number of this outcome in the summary is correct
31-
regex_summary = r"(\d)+ {}".format(label or test_outcome)
31+
regex_summary = rf"(\d)+ {label or test_outcome}"
3232
assert int(re.search(regex_summary, html).group(1)) == test_outcome_number
3333

3434
# Asserts if the generated checkbox of this outcome is correct

0 commit comments

Comments
 (0)