Add typing for context managers returning Self

`Self` was introduced in python 3.11. Use `Self` from typing_extensions for previous Python versions
This commit is contained in:
Edouard Choinière
2025-01-18 00:58:32 +00:00
committed by Scott Talbert
parent 15c6e01231
commit b5e5cb419a
3 changed files with 20 additions and 3 deletions

View File

@@ -32,6 +32,10 @@ from .constants import CPP_ITEMS, VERSION, VALUE_MAP
from .constants import RE_KEEP_SPACES, EXTERN_INHERITANCE
from .constants import DOXYROOT, SPHINXROOT, WIDGETS_IMAGES_ROOT
if sys.version_info >= (3, 11):
from typing import Self
else:
from typing_extensions import Self
# ----------------------------------------------------------------------- #
@@ -622,7 +626,7 @@ class PickleFile(object):
def __init__(self, fileName):
self.fileName = fileName
def __enter__(self):
def __enter__(self) -> Self:
self.read()
return self