1+ from __future__ import annotations
2+
3+ import enum
14import fnmatch
25import os
36from pathlib import Path
47import re
58import sys
69from typing import Any
7- from typing import List
8- from typing import Optional
910from typing import Sequence
10- from typing import Set
11- from typing import Tuple
1211from typing import Union
1312import uuid
1413
@@ -60,7 +59,7 @@ def __init__(self, config, specs=None, defaultchdir="pyexecnetcache") -> None:
6059 self .specs .append (spec )
6160 self .roots = self ._getrsyncdirs ()
6261 self .rsyncoptions = self ._getrsyncoptions ()
63- self ._rsynced_specs : Set [ Tuple [Any , Any ]] = set ()
62+ self ._rsynced_specs : set [ tuple [Any , Any ]] = set ()
6463
6564 def rsync_roots (self , gateway ):
6665 """Rsync the set of roots to the node's gateway cwd."""
@@ -89,7 +88,7 @@ def teardown_nodes(self):
8988 def _getxspecs (self ):
9089 return [execnet .XSpec (x ) for x in parse_spec_config (self .config )]
9190
92- def _getrsyncdirs (self ) -> List [Path ]:
91+ def _getrsyncdirs (self ) -> list [Path ]:
9392 for spec in self .specs :
9493 if not spec .popen or spec .chdir :
9594 break
@@ -174,7 +173,7 @@ def __init__(
174173 self ,
175174 sourcedir : PathLike ,
176175 * ,
177- ignores : Optional [ Sequence [PathLike ]] = None ,
176+ ignores : Sequence [PathLike ] | None = None ,
178177 verbose : bool = True ,
179178 ) -> None :
180179 if ignores is None :
@@ -201,7 +200,7 @@ def _report_send_file(self, gateway, modified_rel_path):
201200 print (f"{ gateway .spec } :{ remotepath } <= { path } " )
202201
203202
204- def make_reltoroot (roots : Sequence [Path ], args : List [str ]) -> List [str ]:
203+ def make_reltoroot (roots : Sequence [Path ], args : list [str ]) -> list [str ]:
205204 # XXX introduce/use public API for splitting pytest args
206205 splitcode = "::"
207206 result = []
@@ -216,7 +215,7 @@ def make_reltoroot(roots: Sequence[Path], args: List[str]) -> List[str]:
216215 result .append (arg )
217216 continue
218217 for root in roots :
219- x : Optional [ Path ]
218+ x : Path | None
220219 try :
221220 x = fspath .relative_to (root )
222221 except ValueError :
@@ -230,9 +229,11 @@ def make_reltoroot(roots: Sequence[Path], args: List[str]) -> List[str]:
230229 return result
231230
232231
233- class WorkerController :
234- ENDMARK = - 1
232+ class Marker (enum .Enum ):
233+ END = - 1
234+
235235
236+ class WorkerController :
236237 class RemoteHook :
237238 @pytest .hookimpl (trylast = True )
238239 def pytest_xdist_getremotemodule (self ):
@@ -283,7 +284,7 @@ def setup(self):
283284 self .channel .send ((self .workerinput , args , option_dict , change_sys_path ))
284285
285286 if self .putevent :
286- self .channel .setcallback (self .process_from_remote , endmarker = self . ENDMARK )
287+ self .channel .setcallback (self .process_from_remote , endmarker = Marker . END )
287288
288289 def ensure_teardown (self ):
289290 if hasattr (self , "channel" ):
@@ -331,7 +332,7 @@ def process_from_remote(self, eventcall):
331332 avoid raising exceptions or doing heavy work.
332333 """
333334 try :
334- if eventcall == self . ENDMARK :
335+ if eventcall is Marker . END :
335336 err = self .channel ._getremoteerror ()
336337 if not self ._down :
337338 if not err or isinstance (err , EOFError ):
@@ -374,16 +375,6 @@ def process_from_remote(self, eventcall):
374375 nodeid = kwargs ["nodeid" ],
375376 fslocation = kwargs ["nodeid" ],
376377 )
377- elif eventname == "warning_captured" :
378- warning_message = unserialize_warning_message (
379- kwargs ["warning_message_data" ]
380- )
381- self .notify_inproc (
382- eventname ,
383- warning_message = warning_message ,
384- when = kwargs ["when" ],
385- item = kwargs ["item" ],
386- )
387378 elif eventname == "warning_recorded" :
388379 warning_message = unserialize_warning_message (
389380 kwargs ["warning_message_data" ]
0 commit comments