@@ -137,19 +137,20 @@ def make_file(self, base: str, path: str) -> None:
137137
138138
139139class DaemonWatchSuite (unittest .TestCase ):
140- def setUp (self ):
140+ def setUp (self ) -> None :
141141 self .temp_dir = tempfile .TemporaryDirectory ()
142142 self .temp_path = pathlib .Path (self .temp_dir .name )
143- self .output_lines = []
143+ self .output_lines : list [ str ] = []
144144 self .stop_reader = False
145145
146- def _read_output (self ):
146+ def _read_output (self ) -> None :
147+ assert self .process .stdout
147148 for line in self .process .stdout :
148149 self .output_lines .append (line .strip ())
149150 if self .stop_reader :
150151 break
151152
152- def _start_watching (self , args : str , start_daemon : bool = True ):
153+ def _start_watching (self , args : str , start_daemon : bool = True ) -> None :
153154 if start_daemon :
154155 subprocess .run (
155156 [sys .executable , "-m" , "mypy.dmypy" , "start" ],
@@ -172,7 +173,7 @@ def _start_watching(self, args: str, start_daemon: bool = True):
172173 self .reader_thread = threading .Thread (target = self ._read_output , daemon = True )
173174 self .reader_thread .start ()
174175
175- def _wait_for_output (self , text : str , timeout = 5 ) :
176+ def _wait_for_output (self , text : str , timeout : int = 5 ) -> bool :
176177 """Wait for text to appear in output within timeout seconds."""
177178 start_time = time .time ()
178179 while time .time () - start_time < timeout :
@@ -181,7 +182,7 @@ def _wait_for_output(self, text: str, timeout=5):
181182 time .sleep (0.1 )
182183 return False
183184
184- def test_watcher_reacts_to_file_changes (self ):
185+ def test_watcher_reacts_to_file_changes (self ) -> None :
185186 (self .temp_path / "valid.py" ).write_text (
186187 "def hello_world() -> str:\n return 'Hello World!'"
187188 )
@@ -198,8 +199,7 @@ def test_watcher_reacts_to_file_changes(self):
198199 self .assertTrue (self ._wait_for_output ("Incompatible return value type" ))
199200 self .assertTrue (self ._wait_for_output ("Found 1 error in 1 file" ))
200201
201- def tearDown (self ):
202- print (self .output_lines )
202+ def tearDown (self ) -> None :
203203 subprocess .run ([sys .executable , "-m" , "mypy.dmypy" , "stop" ], cwd = self .temp_path )
204204
205205 # Send SIGINT to terminate the watcher process
0 commit comments