Skip to content

Commit 6446171

Browse files
committed
Add type hints to magicbot injection tests
Ensure that magicbot doesn't simply break in the presence of type-hinted initialised variables.
1 parent 9a0191e commit 6446171

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tests/magicbot_annotation_tester.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import List
2+
13
import magicbot
24

35

@@ -108,22 +110,26 @@ def createObjects(self):
108110

109111
class TypeHintedComponent:
110112
injectable: Injectable
113+
numbers: List[float]
111114

112115
some_int: int = 1
113116
maybe_float: float = None
114117
calculated_num: float
115118

116119
def __init__(self):
117120
self.calculated_num = 1 - self.some_int
121+
self.numbers = [1, 2.0, 3, 5.0]
118122

119123
def execute(self):
120124
pass
121125

122126

123127
class TypeHintsBot(magicbot.MagicRobot):
124128
injectable: Injectable
129+
injectables: List[Injectable]
125130

126131
component: TypeHintedComponent
127132

128133
def createObjects(self):
129134
self.injectable = Injectable(42)
135+
self.injectables = [self.injectable]

0 commit comments

Comments
 (0)