Skip to content

Commit be0fe13

Browse files
committed
Add mypy to CI pipeline and type outcome.py
1 parent cc80986 commit be0fe13

File tree

11 files changed

+42
-3
lines changed

11 files changed

+42
-3
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ repos:
4444
additional_dependencies:
4545
4646
args: [src]
47+
- repo: https://github.com/pre-commit/mirrors-mypy
48+
rev: v0.790
49+
hooks:
50+
- id: mypy
51+
files: ^(src/pytest_html|testing)
4752
- repo: local
4853
hooks:
4954
- id: rst

setup.cfg

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
11
[bdist_wheel]
22
universal = 0
3+
4+
[mypy]
5+
check_untyped_defs = True
6+
disallow_any_generics = True
7+
disallow_incomplete_defs = True
8+
disallow_untyped_calls = True
9+
disallow_untyped_decorators = True
10+
disallow_untyped_defs = True
11+
ignore_missing_imports = True
12+
no_implicit_optional = True
13+
no_implicit_reexport = True
14+
show_error_codes = True
15+
strict_equality = True
16+
warn_redundant_casts = True
17+
warn_return_any = True
18+
warn_unreachable = True
19+
warn_unused_configs = True

src/pytest_html/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# type: ignore
12
try:
23
from . import __version
34

src/pytest_html/extras.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
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+
# type: ignore
45

56
FORMAT_HTML = "html"
67
FORMAT_IMAGE = "image"

src/pytest_html/hooks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
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+
# type: ignore
45

56

67
def pytest_html_report_title(report):

src/pytest_html/html_report.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# type: ignore
12
import bisect
23
import datetime
34
import json

src/pytest_html/outcome.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1+
from typing import Optional
2+
13
from py.xml import html
24

35

46
class Outcome:
5-
def __init__(self, outcome, total=0, label=None, test_result=None, class_html=None):
7+
def __init__(
8+
self,
9+
outcome: str,
10+
total: int = 0,
11+
label: Optional[str] = None,
12+
test_result: Optional[str] = None,
13+
class_html: Optional[str] = None,
14+
) -> None:
615
self.outcome = outcome
716
self.label = label or outcome
817
self.class_html = class_html or outcome
@@ -12,7 +21,7 @@ def __init__(self, outcome, total=0, label=None, test_result=None, class_html=No
1221
self.generate_checkbox()
1322
self.generate_summary_item()
1423

15-
def generate_checkbox(self):
24+
def generate_checkbox(self) -> None:
1625
checkbox_kwargs = {"data-test-result": self.test_result.lower()}
1726
if self.total == 0:
1827
checkbox_kwargs["disabled"] = "true"
@@ -27,7 +36,7 @@ def generate_checkbox(self):
2736
**checkbox_kwargs,
2837
)
2938

30-
def generate_summary_item(self):
39+
def generate_summary_item(self) -> None:
3140
self.summary_item = html.span(
3241
f"{self.total} {self.label}", class_=self.class_html
3342
)

src/pytest_html/plugin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
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+
# type: ignore
45
import os
56

67
import pytest

src/pytest_html/result.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# type: ignore
12
import json
23
import os
34
import re

src/pytest_html/util.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# type: ignore
12
import importlib
23
from functools import lru_cache
34

0 commit comments

Comments
 (0)