Skip to content

Commit 738bd0e

Browse files
committed
- r enable mypy check_untyped_defs
1 parent cb1f464 commit 738bd0e

File tree

8 files changed

+32
-14
lines changed

8 files changed

+32
-14
lines changed

approval_utilities/list_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from typing import Callable, List, Optional
1+
from typing import Any, Callable, List, Optional
22

33

4-
def format_list(alist: List[str], formatter: Optional[Callable], header: str) -> str:
4+
def format_list(alist: List[Any], formatter: Optional[Callable], header: str) -> str:
55
if formatter is None:
66
formatter = FormatLineItem().print_item
77
text = (header + "\n\n") if header else ""
@@ -14,7 +14,7 @@ class FormatLineItem(object):
1414
def __init__(self) -> None:
1515
self.index = 0
1616

17-
def print_item(self, item: str) -> str:
17+
def print_item(self, item: Any) -> str:
1818
text = str(self.index) + ") " + str(item)
1919
self.index += 1
2020
return text

approval_utilities/utilities/time_utilities.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import os
22

33
from typing_extensions import ContextManager
4+
from typing import Optional
45

56

67
def use_utc_timezone() -> ContextManager:
78
class TimeZoneSwap:
89
def __init__(self):
9-
self.timezone = ""
10+
self.timezone: Optional[str] = ""
1011

1112
def __enter__(self):
1213
self.timezone = os.environ.get("TZ")

approvaltests/approvals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def verify_file(
325325

326326
def verify_all(
327327
header: str,
328-
alist: List[str],
328+
alist: List[Any],
329329
formatter: Optional[Callable] = None,
330330
reporter: Optional[DiffReporter] = None,
331331
encoding: None = None,

approvaltests/reporters/default_reporter_factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
DEFAULT_REPORTER = local()
77

88

9-
def set_default_reporter(reporter: Reporter) -> None:
9+
def set_default_reporter(reporter: Optional[Reporter]) -> None:
1010
DEFAULT_REPORTER.v = reporter
1111

1212

approvaltests/string_writer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class StringWriter(Writer):
1111

1212
def __init__(
1313
self,
14-
contents: str,
14+
contents: Optional[str],
1515
extension: str = ".txt",
1616
encoding: Optional[str] = None,
1717
errors: Optional[str] = None,

mypy.ini

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ disallow_incomplete_defs = False
88
disallow_untyped_calls = False
99
disallow_untyped_defs = False
1010
disallow_any_generics = False
11-
check_untyped_defs = False
1211
no_implicit_reexport = False
1312
disallow_subclassing_any = False
1413
# End strict mode overrides
@@ -46,11 +45,14 @@ disable_error_code = misc
4645
disable_error_code = empty-body, no-any-return, import-not-found
4746

4847
[mypy-tests.executable_commands.test_sql_loader]
49-
disable_error_code = return-value
48+
disable_error_code = return-value, arg-type
5049

5150
[mypy-tests.test_inline_approvals]
5251
disable_error_code = no-any-return
5352

53+
[mypy-tests.test_fileapprover]
54+
disable_error_code = arg-type
55+
5456
[mypy-tests.mrjob.test_mrjob]
5557
disable_error_code = import-untyped
5658

@@ -90,5 +92,17 @@ disable_error_code = arg-type, import-untyped
9092
[mypy-approvaltests.inline.parse]
9193
disable_error_code = no-any-return, arg-type
9294

95+
[mypy-approvaltests.reporters.generic_diff_reporter_config]
96+
disable_error_code = arg-type
97+
98+
[mypy-approvaltests.reporters.diff_reporter]
99+
disable_error_code = name-defined
100+
101+
[mypy-tests.scrubbers.test_scrubbers]
102+
disable_error_code = arg-type
103+
104+
[mypy-tests.test_simple_logger]
105+
disable_error_code = assignment
106+
93107
[mypy-approvaltests.integrations.pytest.py_test_namer]
94108
disable_error_code = attr-defined

tests/test_compare_file_lists.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
def compare_log_and_file_system(log_file_names, fs_file_names):
1+
from typing import List
2+
3+
4+
def compare_log_and_file_system(log_file_names: List[str], fs_file_names: List[str]):
25
return [file for file in fs_file_names if file not in log_file_names]
36

47

58
def test_returns_empty_list_for_two_empty_lists():
6-
log_file_names = []
7-
fs_file_names = []
9+
log_file_names: List[str] = []
10+
fs_file_names: List[str] = []
811
assert compare_log_and_file_system(log_file_names, fs_file_names) == []
912

1013

tests/test_verify.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import pytest
99

10-
from approvaltests import Options, delete_approved_file, approvals
10+
from approvaltests import Options, delete_approved_file, approvals, List
1111
from approvaltests.approval_exception import ApprovalException
1212
from approvaltests.approvals import (
1313
verify,
@@ -139,7 +139,7 @@ def test_verify_as_json_raises_type_error_for_non_renderable_types(self):
139139
verify_as_json(Ellipsis, self.reporter)
140140

141141
def test_verify_as_json_raises_value_error_for_non_renderable_values(self):
142-
circular_data = []
142+
circular_data: List[List] = []
143143
circular_data.append(circular_data)
144144
with self.assertRaises(ValueError):
145145
verify_as_json(circular_data, self.reporter)

0 commit comments

Comments
 (0)