From 546f60c6f67dc43a92c881ebb05ffb55f68bccaa Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 18 Sep 2024 14:19:46 +0200 Subject: [PATCH] Heuristics for ActorList.filter --- PythonAPI/carla/source/carla/libcarla.pyi | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/PythonAPI/carla/source/carla/libcarla.pyi b/PythonAPI/carla/source/carla/libcarla.pyi index 3d1db5606ab..cb96aa300f6 100644 --- a/PythonAPI/carla/source/carla/libcarla.pyi +++ b/PythonAPI/carla/source/carla/libcarla.pyi @@ -546,6 +546,23 @@ class ActorList(Generic[__Actor]): The list is automatically created and updated by the server and it can be returned using `carla.World`. """ + # Heuristic to infer type without Generic + + @overload + def filter(self, wildcard_pattern: Literal['traffic_light.*']) -> ActorList[TrafficLight]: ... + + @overload + def filter(self, wildcard_pattern: Literal['vehicle.*']) -> ActorList[Vehicle]: ... + + @overload + def filter(self, wildcard_pattern: Literal['walker.pedestrian.*', 'walker.*']) -> ActorList[Walker]: ... + + @overload + def filter(self, wildcard_pattern: Literal['sensor.*']) -> ActorList[Sensor]: ... + + @overload + def filter(self, wildcard_pattern: str) -> ActorList[__Actor]: ... + # region Methods def filter(self, wildcard_pattern: str) -> ActorList[__Actor]: """Filters a list of Actors matching wildcard_pattern against their variable `type_id` (which identifies the blueprint used to spawn them). Matching follows fnmatch standard.