Skip to content

Commit

Permalink
Add type hints for returns
Browse files Browse the repository at this point in the history
  • Loading branch information
Hailin-Wang committed Jul 24, 2022
1 parent ee26194 commit b1ef8f1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions ribbon/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def setCategoryStyle(self, style: RibbonCategoryStyle):
self._style = style
self.repaint()

def categoryStyle(self):
def categoryStyle(self) -> RibbonCategoryStyle:
"""Return the button style of the category.
:return: The button style.
Expand Down Expand Up @@ -125,7 +125,7 @@ def removePanel(self, title: str):
self._panelLayoutWidget.removeWidget(self._panels[title])
self._panels.pop(title)

def takePanel(self, title: str):
def takePanel(self, title: str) -> RibbonPanel:
"""Remove and return a panel from the category.
:param title: The title of the panel.
Expand All @@ -135,7 +135,7 @@ def takePanel(self, title: str):
self.removePanel(title)
return panel

def panel(self, title: str):
def panel(self, title: str) -> RibbonPanel:
"""Return a panel from the category.
:param title: The title of the panel.
Expand Down
2 changes: 1 addition & 1 deletion ribbon/categorylayoutwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def removeWidget(self, widget: QtWidgets.QWidget):
"""
self._categoryLayout.removeWidget(widget)

def takeWidget(self, widget: QtWidgets.QWidget):
def takeWidget(self, widget: QtWidgets.QWidget) -> QtWidgets.QWidget:
"""Remove and return a widget from the category layout.
:param widget: The widget to remove.
Expand Down
7 changes: 4 additions & 3 deletions ribbon/ribbonbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from qtpy import QtWidgets, QtCore, QtGui

from . import RibbonTabBar
from .category import RibbonCategory, RibbonContextCategory, RibbonNormalCategory, RibbonCategoryStyle, contextColors
from .separator import RibbonHorizontalSeparator
from .titlewidget import RibbonTitleWidget
Expand Down Expand Up @@ -89,7 +90,7 @@ def setRibbonStyle(self, style: RibbonStyle):
elif style == RibbonStyle.Debug:
self.setStyleSheet(open(data_file_path(f"styles/{stylefiles[style]}.qss"), "r").read())

def applicationOptionButton(self):
def applicationOptionButton(self) -> QtWidgets.QToolButton:
"""Return the application button."""
return self._titleWidget.applicationButton()

Expand Down Expand Up @@ -124,7 +125,7 @@ def setRibbonHeight(self, height: int):
self._ribbonHeight = height
self.setFixedHeight(height)

def tabBar(self):
def tabBar(self) -> RibbonTabBar:
"""Return the tab bar of the ribbon.
:return: The tab bar of the ribbon.
Expand Down Expand Up @@ -167,7 +168,7 @@ def setQuickAccessButtonHeight(self, height: int = 40):
"""
self._titleWidget.setQuickAccessButtonHeight(height)

def title(self):
def title(self) -> str:
"""Return the title of the ribbon.
:return: The title of the ribbon.
Expand Down
4 changes: 2 additions & 2 deletions ribbon/titlewidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def __init__(self, title='PyQtRibbon', parent=None):

self._collapseRibbonButton.clicked.connect(self.collapseRibbonButtonClicked)

def applicationButton(self):
def applicationButton(self) -> RibbonApplicationButton:
"""Return the application button."""
return self._applicationButton

Expand Down Expand Up @@ -193,7 +193,7 @@ def setQuickAccessButtonHeight(self, height: int = 40):
for button in self._quickAccessButtons:
button.setIconSize(QtCore.QSize(height, height))

def title(self):
def title(self) -> str:
"""Return the title of the ribbon.
:return: The title of the ribbon.
Expand Down

0 comments on commit b1ef8f1

Please sign in to comment.