Skip to content

Commit

Permalink
Add typing annotations to methods returning self.
Browse files Browse the repository at this point in the history
  • Loading branch information
echoix committed Jan 18, 2025
1 parent fee14c6 commit 6c9372a
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 119 deletions.
9 changes: 7 additions & 2 deletions etgtools/extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
textfile_open
from sphinxtools.utilities import findDescendants

if sys.version_info >= (3, 11):
from typing import Self
else:
from typing_extensions import Self

#---------------------------------------------------------------------------
# These classes simply hold various bits of information about the classes,
# methods, functions and other items in the C/C++ API being wrapped.
Expand Down Expand Up @@ -98,7 +103,7 @@ def clearDeprecated(self):
return


def ignore(self, val=True):
def ignore(self, val=True) -> Self:
self.ignored = val
return self

Expand Down Expand Up @@ -426,7 +431,7 @@ def renameOverload(self, matchText, newName, **kw):
return item


def ignore(self, val=True):
def ignore(self, val=True) -> Self:
# In addition to ignoring this item, reorder any overloads to ensure
# the primary overload is not ignored, if possible.
super(FunctionDef, self).ignore(val)
Expand Down
31 changes: 18 additions & 13 deletions wx/lib/agw/aui/aui_switcherdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,17 @@ def OnSwitchPane(self, event):
"""

import sys
import wx

from . import auibook
from .aui_utilities import FindFocusDescendant
from .aui_constants import SWITCHER_TEXT_MARGIN_X, SWITCHER_TEXT_MARGIN_Y

if sys.version_info >= (3, 11):
from typing import Self
else:
from typing_extensions import Self

# Define a translation function
_ = wx.GetTranslation
Expand Down Expand Up @@ -213,7 +218,7 @@ def Copy(self, item):
self._window = item._window


def SetTitle(self, title):
def SetTitle(self, title) -> Self:

self._title = title
return self
Expand All @@ -224,7 +229,7 @@ def GetTitle(self):
return self._title


def SetName(self, name):
def SetName(self, name) -> Self:

self._name = name
return self
Expand All @@ -235,7 +240,7 @@ def GetName(self):
return self._name


def SetDescription(self, descr):
def SetDescription(self, descr) -> Self:

self._description = descr
return self
Expand All @@ -246,7 +251,7 @@ def GetDescription(self):
return self._description


def SetId(self, id):
def SetId(self, id) -> Self:

self._id = id
return self
Expand All @@ -257,7 +262,7 @@ def GetId(self):
return self._id


def SetIsGroup(self, isGroup):
def SetIsGroup(self, isGroup) -> Self:

self._isGroup = isGroup
return self
Expand All @@ -268,7 +273,7 @@ def GetIsGroup(self):
return self._isGroup


def BreakColumn(self, breakCol=True):
def BreakColumn(self, breakCol=True) -> Self:

self._breakColumn = breakCol
return self
Expand All @@ -279,7 +284,7 @@ def GetBreakColumn(self):
return self._breakColumn


def SetRect(self, rect):
def SetRect(self, rect) -> Self:

self._rect = rect
return self
Expand All @@ -290,7 +295,7 @@ def GetRect(self):
return self._rect


def SetTextColour(self, colour):
def SetTextColour(self, colour) -> Self:

self._textColour = colour
return self
Expand All @@ -301,7 +306,7 @@ def GetTextColour(self):
return self._textColour


def SetFont(self, font):
def SetFont(self, font) -> Self:

self._font = font
return self
Expand All @@ -312,7 +317,7 @@ def GetFont(self):
return self._font


def SetBitmap(self, bitmap):
def SetBitmap(self, bitmap) -> Self:

self._bitmap = bitmap
return self
Expand All @@ -323,7 +328,7 @@ def GetBitmap(self):
return self._bitmap


def SetRowPos(self, pos):
def SetRowPos(self, pos) -> Self:

self._rowPos = pos
return self
Expand All @@ -334,7 +339,7 @@ def GetRowPos(self):
return self._rowPos


def SetColPos(self, pos):
def SetColPos(self, pos) -> Self:

self._colPos = pos
return self
Expand All @@ -345,7 +350,7 @@ def GetColPos(self):
return self._colPos


def SetWindow(self, win):
def SetWindow(self, win) -> Self:

self._window = win
return self
Expand Down
Loading

0 comments on commit 6c9372a

Please sign in to comment.