mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2025-12-16 01:30:07 +01:00
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:
committed by
Scott Talbert
parent
15c6e01231
commit
b5e5cb419a
@@ -13,9 +13,15 @@ A class like :class:`wx.BusyInfo` but which doesn't take up so much space by def
|
||||
and which has a nicer look.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import wx
|
||||
from wx.lib.stattext import GenStaticText as StaticText
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
from typing import Self
|
||||
else:
|
||||
from typing_extensions import Self
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -68,7 +74,7 @@ class BusyInfo(object):
|
||||
|
||||
|
||||
# Magic methods for using this class as a Context Manager
|
||||
def __enter__(self):
|
||||
def __enter__(self) -> Self:
|
||||
return self
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
self.Close()
|
||||
|
||||
@@ -13,6 +13,7 @@ This is a collection of utilities used by the :mod:`wx.lib.plot` package.
|
||||
__docformat__ = "restructuredtext en"
|
||||
|
||||
# Standard Library
|
||||
import sys
|
||||
import functools
|
||||
import inspect
|
||||
import itertools
|
||||
@@ -22,6 +23,12 @@ from warnings import warn as _warn
|
||||
import wx
|
||||
import numpy as np
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
from typing import Self
|
||||
else:
|
||||
from typing_extensions import Self
|
||||
|
||||
|
||||
class PlotPendingDeprecation(wx.wxPyDeprecationWarning):
|
||||
pass
|
||||
|
||||
@@ -195,7 +202,7 @@ class TempStyle(object):
|
||||
|
||||
return wrapper
|
||||
|
||||
def __enter__(self):
|
||||
def __enter__(self) -> Self:
|
||||
self._save_items(self.dc)
|
||||
return self
|
||||
|
||||
|
||||
Reference in New Issue
Block a user