From a959577ccf6ba7496f342b8cedf22d2c0bf414f0 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 29 Jul 2024 15:19:38 +0200 Subject: [PATCH] Better usage of Enum if typing.Self is availiable Using Self will not report an override / incompatible error. --- PythonAPI/carla/source/carla/libcarla.pyi | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/PythonAPI/carla/source/carla/libcarla.pyi b/PythonAPI/carla/source/carla/libcarla.pyi index edb594432..b5a74c368 100644 --- a/PythonAPI/carla/source/carla/libcarla.pyi +++ b/PythonAPI/carla/source/carla/libcarla.pyi @@ -1,14 +1,19 @@ from enum import Enum +import sys from typing import Callable, Iterable, Iterator, Union, Optional, overload, ClassVar, Any, Literal - +if sys.version_info < (3, 11): + from typing_extensions import Self +else: + from typing import Self + class __CarlaEnum(Enum): """ - CARLA's Enums have a `values` entry that is not part of the python enum.Enum class. - This abstract class adds this method. + CARLA's Enums have a `values` and `names` attribute that are not part of the python `enum.Enum` + class. This abstract stub class adds these attributes. """ - values : ClassVar[dict[int, "__CarlaEnum"]] - names : ClassVar[dict[str, "__CarlaEnum"]] + values : ClassVar[dict[int, Self]] + names : ClassVar[dict[str, Self]] def __init_subclass__(cls): cls.values : dict[int, cls]