Skip to content

Commit 89742a7

Browse files
committed
- r add type hints
1 parent fcca1d9 commit 89742a7

14 files changed

Lines changed: 26 additions & 26 deletions

approval_utilities/utilities/clipboard_utilities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
def copy_to_clipboard(text):
1+
def copy_to_clipboard(text: str) -> None:
22
"""
33
This acts as a wrapper to defer the importing of pyperclip util actual usage
44
"""

approval_utilities/utilities/logger/logging_instance.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def print_type(value):
2828

2929

3030
class LoggingInstance:
31-
def __init__(self):
31+
def __init__(self) -> None:
3232
self.log_stack_traces = True
3333
self.toggles = Toggles(True)
3434
self.previous_timestamp = None
@@ -112,7 +112,7 @@ def log_line(self, text: str, use_timestamps=True) -> None:
112112
output_message = f"{timestamp}{self.get_tabs()}{text}\n"
113113
self.logger(output_message)
114114

115-
def get_timestamp(self) -> str:
115+
def get_timestamp(self):
116116
timestamp = ""
117117
if self.log_with_timestamps:
118118
time1: datetime.datetime = self.timer()

approval_utilities/utilities/map_reduce.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import itertools
2-
from typing import Sequence, Any, Callable
2+
from typing import Sequence, Any, Callable, Generator, Dict
33

44

55
def first(sequence: Sequence[Any], predicate: Callable[[Any], bool]) -> Any:
66
matching = filter(predicate, sequence)
77
return next(matching, None)
88

99

10-
def product_dict(**kwargs):
10+
def product_dict(**kwargs: Sequence[Any]) -> Generator[Dict[str, Any], None, None]:
1111
"""
1212
Similar to `itertools.product`, but the resulting combinations retain the names.
1313
"""

approval_utilities/utilities/markdown_table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
class MarkdownTable(Verifiable):
11-
def __init__(self):
11+
def __init__(self) -> None:
1212
self.markdown: str = ""
1313

1414
def get_verify_parameters(self, options: "Options") -> VerifyParameters:
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
class StringWrapper:
2-
def __init__(self):
2+
def __init__(self) -> None:
33
self.string = ""
44

5-
def append(self, text):
5+
def append(self, text: str) -> None:
66
self.string += text
77

8-
def __str__(self):
8+
def __str__(self) -> str:
99
return self.string
1010

11-
def __repr__(self):
11+
def __repr__(self) -> str:
1212
return self.string

approvaltests/approval_exception.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ def __init__(self, value: str) -> None:
33
super().__init__(self)
44
self.value = value
55

6-
def __str__(self):
6+
def __str__(self) -> str:
77
return self.value
88

99

approvaltests/inline/split_code.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33

44

55
class SplitCode:
6-
def __init__(self, before_method, after_method, tab):
6+
def __init__(self, before_method: str, after_method: str, tab: str) -> None:
77
self.before_method = before_method
88
self.after_method = after_method
99
self.tab = tab
1010

11-
def __str__(self):
11+
def __str__(self) -> str:
1212
return f"before:\n{self.before_method}\nafter:\n{self.after_method}\ntab: '{self.tab}'\n"
1313

1414
@staticmethod
15-
def on_method(code, method_name) -> "SplitCode":
15+
def on_method(code: str, method_name: str) -> "SplitCode":
1616
lines = code.split("\n")
1717
before = []
1818
after = []
@@ -51,7 +51,7 @@ class State(Enum):
5151
after.append(line)
5252
return SplitCode("\n".join(before), "\n".join(after), tab)
5353

54-
def indent(self, received_text):
54+
def indent(self, received_text: str) -> str:
5555
lines = received_text.split("\n")
5656
indented_lines = [f"{self.tab}{line}" for line in lines]
5757
return "\n".join(indented_lines)

approvaltests/integrations/pytest/pytest_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ class PytestConfig:
22
test_naming_patterns = ["test_*"]
33

44
@staticmethod
5-
def set_config(config):
5+
def set_config(config) -> None:
66
PytestConfig.test_naming_patterns = config.getini("python_functions")
77

88

9-
def set_pytest_config(config):
9+
def set_pytest_config(config) -> None:
1010
PytestConfig.set_config(config)

approvaltests/namer/inline_comparator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def get_received_filename(self, base: Optional[str] = None) -> str:
2323
return tempfile.NamedTemporaryFile(suffix=".received.txt", delete=False).name
2424

2525
@staticmethod
26-
def get_test_method_doc_string():
26+
def get_test_method_doc_string() -> str:
2727
test_stack_frame: FrameInfo = StackFrameNamer.get_test_frame()
2828
method: Callable[..., Any] = InlineComparator.get_caller_method(
2929
test_stack_frame

approvaltests/namer/inline_python_reporter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def report(self, received_path: str, approved_path: str) -> bool:
2323
received_path = self.create_received_file(received_path, test_source_file)
2424
return self.diffReporter.report(received_path, test_source_file)
2525

26-
def get_test_source_file(self):
26+
def get_test_source_file(self) -> str:
2727
test_stack_frame: FrameInfo = StackFrameNamer.get_test_frame()
2828
return test_stack_frame.filename
2929

0 commit comments

Comments
 (0)