diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index aca4b0309..e522314d0 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -53,7 +53,7 @@ jobs: - name: Upload coverage to Codecov if: runner.os == 'Windows' && matrix.python-version == '3.11' - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} - name: Create documentation diff --git a/prettyqt/charts/chart.py b/prettyqt/charts/chart.py index 2d448e08d..94bb8fe00 100644 --- a/prettyqt/charts/chart.py +++ b/prettyqt/charts/chart.py @@ -17,18 +17,16 @@ "Qt", ] -THEMES: bidict[ThemeStr, charts.QChart.ChartTheme] = bidict( - { - "Light": charts.QChart.ChartTheme.ChartThemeLight, - "Blue Cerulean": charts.QChart.ChartTheme.ChartThemeBlueCerulean, - "Dark": charts.QChart.ChartTheme.ChartThemeDark, - "Brown Sand": charts.QChart.ChartTheme.ChartThemeBrownSand, - "Blue NCS": charts.QChart.ChartTheme.ChartThemeBlueNcs, - "High Contrast": charts.QChart.ChartTheme.ChartThemeHighContrast, - "Blue Icy": charts.QChart.ChartTheme.ChartThemeBlueIcy, - "Qt": charts.QChart.ChartTheme.ChartThemeQt, - } -) +THEMES: bidict[ThemeStr, charts.QChart.ChartTheme] = bidict({ + "Light": charts.QChart.ChartTheme.ChartThemeLight, + "Blue Cerulean": charts.QChart.ChartTheme.ChartThemeBlueCerulean, + "Dark": charts.QChart.ChartTheme.ChartThemeDark, + "Brown Sand": charts.QChart.ChartTheme.ChartThemeBrownSand, + "Blue NCS": charts.QChart.ChartTheme.ChartThemeBlueNcs, + "High Contrast": charts.QChart.ChartTheme.ChartThemeHighContrast, + "Blue Icy": charts.QChart.ChartTheme.ChartThemeBlueIcy, + "Qt": charts.QChart.ChartTheme.ChartThemeQt, +}) AnimationOptionStr = Literal["none", "grid_axis", "series", "all"] diff --git a/prettyqt/core/animationgroup.py b/prettyqt/core/animationgroup.py index 819c72f09..19f673c7a 100644 --- a/prettyqt/core/animationgroup.py +++ b/prettyqt/core/animationgroup.py @@ -13,14 +13,12 @@ class AnimationGroupMixin(core.AbstractAnimationMixin): @overload - def __getitem__(self, index: int) -> core.QAbstractAnimation: - ... + def __getitem__(self, index: int) -> core.QAbstractAnimation: ... @overload def __getitem__( self, index: slice - ) -> listdelegators.ListDelegator[core.QAbstractAnimation]: - ... + ) -> listdelegators.ListDelegator[core.QAbstractAnimation]: ... def __getitem__(self, index: int | slice): count = self.animationCount() diff --git a/prettyqt/core/operatingsystemversion.py b/prettyqt/core/operatingsystemversion.py index c0c492302..0be78e1c7 100644 --- a/prettyqt/core/operatingsystemversion.py +++ b/prettyqt/core/operatingsystemversion.py @@ -87,14 +87,12 @@ def __eq__(self, other): ) def __hash__(self): - return hash( - ( - self.get_type(), - self.majorVersion(), - self.minorVersion(), - self.microVersion(), - ) - ) + return hash(( + self.get_type(), + self.majorVersion(), + self.minorVersion(), + self.microVersion(), + )) def get_type(self) -> OsTypeStr: """Get current os type. diff --git a/prettyqt/custom_widgets/itemviews/filterheader.py b/prettyqt/custom_widgets/itemviews/filterheader.py index 054f6adfb..4b791d11e 100644 --- a/prettyqt/custom_widgets/itemviews/filterheader.py +++ b/prettyqt/custom_widgets/itemviews/filterheader.py @@ -27,7 +27,7 @@ class FilterHeader(widgets.HeaderView): model = MyModel() widget = widgets.TableView() widget.set_model(model) - widget.h_header = custom_widgets.FilterHeader() # same as setHorizontalHeader() + widget.h_header = custom_widgets.FilterHeader() # same as setHorizontalHeader() ``` and you will get filter capabilities for your table. diff --git a/prettyqt/custom_widgets/objectbrowser.py b/prettyqt/custom_widgets/objectbrowser.py index 17f335ba4..a9f8c4378 100644 --- a/prettyqt/custom_widgets/objectbrowser.py +++ b/prettyqt/custom_widgets/objectbrowser.py @@ -1,6 +1,5 @@ """Object browser GUI in Qt.""" - from __future__ import annotations import logging diff --git a/prettyqt/custom_widgets/scrollareatocwidget.py b/prettyqt/custom_widgets/scrollareatocwidget.py index d1bb89748..14d0903f6 100644 --- a/prettyqt/custom_widgets/scrollareatocwidget.py +++ b/prettyqt/custom_widgets/scrollareatocwidget.py @@ -367,7 +367,7 @@ def set_always_expanded(self, always_expanded: bool): for i in range(10): section = SectionWidget(window_title=f"test{i}") section.box.add(SectionWidget(window_title=f"{i}nested")) - section.box.add(SectionWidget(window_title=f"{i*10}nested")) + section.box.add(SectionWidget(window_title=f"{i * 10}nested")) scroll_layout.add(section) window.show() app.exec() diff --git a/prettyqt/debugging/package_info.py b/prettyqt/debugging/package_info.py index 9e34cc5b8..6f078ec2c 100644 --- a/prettyqt/debugging/package_info.py +++ b/prettyqt/debugging/package_info.py @@ -27,9 +27,9 @@ def get_all_qt_enums(): if isinstance(i[1], enum.EnumType) ] - all_qt_enums.extend( - [i[1] for i in inspect.getmembers(core.Qt) if isinstance(i[1], enum.EnumType)] - ) + all_qt_enums.extend([ + i[1] for i in inspect.getmembers(core.Qt) if isinstance(i[1], enum.EnumType) + ]) return all_qt_enums diff --git a/prettyqt/itemdelegates/radiodelegate.py b/prettyqt/itemdelegates/radiodelegate.py index 66ff11a0c..666cdb1dd 100644 --- a/prettyqt/itemdelegates/radiodelegate.py +++ b/prettyqt/itemdelegates/radiodelegate.py @@ -96,7 +96,9 @@ def setModelData( button = editor.button_group.checkedId() if button >= 0: model.setData( - index, self.items[button], constants.DISPLAY_ROLE # type: ignore + index, + self.items[button], + constants.DISPLAY_ROLE, # type: ignore ) self.choices[button] = index.row() diff --git a/prettyqt/itemmodels/astmodel.py b/prettyqt/itemmodels/astmodel.py index cac6c66b4..c02d8d175 100644 --- a/prettyqt/itemmodels/astmodel.py +++ b/prettyqt/itemmodels/astmodel.py @@ -10,35 +10,33 @@ SOURCE_FONT = gui.Font.mono(as_qt=True) -NODE_MAP = bidict( - { - ast.Add: "+", - ast.Sub: "-", - ast.Mult: "*", - ast.Div: "/", - ast.Mod: "%", - ast.Eq: "==", - ast.In: "in", - ast.Pow: "**", - ast.MatMult: "@", - ast.FloorDiv: "//", - ast.BitAnd: "&", - ast.BitOr: "|", - ast.BitXor: "^", - ast.Gt: ">", - ast.GtE: ">=", - ast.Lt: "<", - ast.LtE: "<=", - ast.Is: "is", - ast.NotEq: "!=", - ast.IsNot: "is not", - ast.Not: "not ", - ast.NotIn: "not in", - ast.And: "and", - ast.Or: "or", - ast.Invert: "~", - } -) +NODE_MAP = bidict({ + ast.Add: "+", + ast.Sub: "-", + ast.Mult: "*", + ast.Div: "/", + ast.Mod: "%", + ast.Eq: "==", + ast.In: "in", + ast.Pow: "**", + ast.MatMult: "@", + ast.FloorDiv: "//", + ast.BitAnd: "&", + ast.BitOr: "|", + ast.BitXor: "^", + ast.Gt: ">", + ast.GtE: ">=", + ast.Lt: "<", + ast.LtE: "<=", + ast.Is: "is", + ast.NotEq: "!=", + ast.IsNot: "is not", + ast.Not: "not ", + ast.NotIn: "not in", + ast.And: "and", + ast.Or: "or", + ast.Invert: "~", +}) logger = logging.getLogger(__name__) @@ -57,6 +55,7 @@ class AstModel(itemmodels.TreeModel): ### Example: ```py import ast + view = TreeView() code = pathlib.Path(__file__).read_text() tree = ast.parse(code) diff --git a/prettyqt/itemmodels/proxies/changeheadersproxymodel.py b/prettyqt/itemmodels/proxies/changeheadersproxymodel.py index bb5f6e66a..78fb34a1e 100644 --- a/prettyqt/itemmodels/proxies/changeheadersproxymodel.py +++ b/prettyqt/itemmodels/proxies/changeheadersproxymodel.py @@ -17,9 +17,10 @@ class ChangeHeadersProxyModel(core.IdentityProxyModel): ### Example ```py - table.proxifier.change_headers(header=["x", "y", "z"], + table.proxifier.change_headers( + header=["x", "y", "z"], orientation=constants.HORIZONTAL, - role=constants.DISPLAY_ROLE + role=constants.DISPLAY_ROLE, ) table.show() # or diff --git a/prettyqt/itemmodels/proxies/columnjoinerproxymodel.py b/prettyqt/itemmodels/proxies/columnjoinerproxymodel.py index 0d6ae46bd..0d4d4c736 100644 --- a/prettyqt/itemmodels/proxies/columnjoinerproxymodel.py +++ b/prettyqt/itemmodels/proxies/columnjoinerproxymodel.py @@ -52,7 +52,6 @@ class ColumnJoinerProxyModel(core.AbstractProxyModel): table.set_model(model) # table.proxifier.add_column(header="Full name", formatter="{1}, {0}") table.show() - ```
![Image title](../../images/columnjoinerproxymodel_before.png) diff --git a/prettyqt/itemmodels/proxies/meltproxymodel.py b/prettyqt/itemmodels/proxies/meltproxymodel.py index 21cadcb53..702da466d 100644 --- a/prettyqt/itemmodels/proxies/meltproxymodel.py +++ b/prettyqt/itemmodels/proxies/meltproxymodel.py @@ -28,7 +28,6 @@ class MeltProxyModel(core.AbstractProxyModel): table.set_model(model) # table.proxifier.melt(id_columns=[0, 1]) table.show() - ```
![Image title](../../images/meltproxymodel_before.png) diff --git a/prettyqt/itemmodels/proxies/tabletolistproxymodel.py b/prettyqt/itemmodels/proxies/tabletolistproxymodel.py index 5cc185401..b39fcac6b 100644 --- a/prettyqt/itemmodels/proxies/tabletolistproxymodel.py +++ b/prettyqt/itemmodels/proxies/tabletolistproxymodel.py @@ -24,7 +24,6 @@ class TableToListProxyModel(core.IdentityProxyModel): table.set_model(model) # table.proxifier.to_list() table.show() - ```
![Image title](../../images/tabletolistproxymodel_before.png) diff --git a/prettyqt/itemmodels/tupletreemodel.py b/prettyqt/itemmodels/tupletreemodel.py index 532eeaf2e..b7225163c 100644 --- a/prettyqt/itemmodels/tupletreemodel.py +++ b/prettyqt/itemmodels/tupletreemodel.py @@ -59,8 +59,11 @@ def data( @classmethod def supports(cls, instance) -> bool: match instance: - case dict() if all( - isinstance(k, pathlib.Path | tuple) for k in instance.keys() and instance + case dict() if ( + all( + isinstance(k, pathlib.Path | tuple) + for k in instance.keys() and instance + ) ): return True return False diff --git a/prettyqt/itemmodels/widgetsdetailsmodel.py b/prettyqt/itemmodels/widgetsdetailsmodel.py index 293097777..f806959bc 100644 --- a/prettyqt/itemmodels/widgetsdetailsmodel.py +++ b/prettyqt/itemmodels/widgetsdetailsmodel.py @@ -60,9 +60,9 @@ def data( if isinstance(value, bool) and role == constants.CHECKSTATE_ROLE: return self.to_checkstate(value) match role: - case ( - constants.DISPLAY_ROLE | constants.EDIT_ROLE | constants.USER_ROLE - ) if not isinstance(value, bool): + case constants.DISPLAY_ROLE | constants.EDIT_ROLE | constants.USER_ROLE if ( + not isinstance(value, bool) + ): return value def setData( diff --git a/prettyqt/multimedia/audioformat.py b/prettyqt/multimedia/audioformat.py index c2508665e..42fb6f9a7 100644 --- a/prettyqt/multimedia/audioformat.py +++ b/prettyqt/multimedia/audioformat.py @@ -21,20 +21,18 @@ ] CHANNEL_CONFIG: bidict[ChannelConfigStr, QtMultimedia.QAudioFormat.ChannelConfig] = ( - bidict( - **{ - "unknown": QtMultimedia.QAudioFormat.ChannelConfig.ChannelConfigUnknown, - "mono": QtMultimedia.QAudioFormat.ChannelConfig.ChannelConfigMono, - "stereo": QtMultimedia.QAudioFormat.ChannelConfig.ChannelConfigStereo, - "2_1": QtMultimedia.QAudioFormat.ChannelConfig.ChannelConfig2Dot1, - "3_0": QtMultimedia.QAudioFormat.ChannelConfig.ChannelConfig3Dot0, - "3_1": QtMultimedia.QAudioFormat.ChannelConfig.ChannelConfig3Dot1, - "5_0": QtMultimedia.QAudioFormat.ChannelConfig.ChannelConfigSurround5Dot0, - "5_1": QtMultimedia.QAudioFormat.ChannelConfig.ChannelConfigSurround5Dot1, - "7_0": QtMultimedia.QAudioFormat.ChannelConfig.ChannelConfigSurround7Dot0, - "7_1": QtMultimedia.QAudioFormat.ChannelConfig.ChannelConfigSurround7Dot1, - } - ) + bidict(**{ + "unknown": QtMultimedia.QAudioFormat.ChannelConfig.ChannelConfigUnknown, + "mono": QtMultimedia.QAudioFormat.ChannelConfig.ChannelConfigMono, + "stereo": QtMultimedia.QAudioFormat.ChannelConfig.ChannelConfigStereo, + "2_1": QtMultimedia.QAudioFormat.ChannelConfig.ChannelConfig2Dot1, + "3_0": QtMultimedia.QAudioFormat.ChannelConfig.ChannelConfig3Dot0, + "3_1": QtMultimedia.QAudioFormat.ChannelConfig.ChannelConfig3Dot1, + "5_0": QtMultimedia.QAudioFormat.ChannelConfig.ChannelConfigSurround5Dot0, + "5_1": QtMultimedia.QAudioFormat.ChannelConfig.ChannelConfigSurround5Dot1, + "7_0": QtMultimedia.QAudioFormat.ChannelConfig.ChannelConfigSurround7Dot0, + "7_1": QtMultimedia.QAudioFormat.ChannelConfig.ChannelConfigSurround7Dot1, + }) ) diff --git a/prettyqt/positioning/geocoordinate.py b/prettyqt/positioning/geocoordinate.py index 26e6dcb10..f370bd6ce 100644 --- a/prettyqt/positioning/geocoordinate.py +++ b/prettyqt/positioning/geocoordinate.py @@ -27,13 +27,11 @@ ] -COORDINATE_TYPE = bidict( - { - "invalid": mod.CoordinateType.InvalidCoordinate, - "2d": mod.CoordinateType.Coordinate2D, - "3d": mod.CoordinateType.Coordinate3D, - } -) +COORDINATE_TYPE = bidict({ + "invalid": mod.CoordinateType.InvalidCoordinate, + "2d": mod.CoordinateType.Coordinate2D, + "3d": mod.CoordinateType.Coordinate3D, +}) CoordinateTypeStr = Literal["invalid", "2d", "3d"] diff --git a/prettyqt/utils/datatypes.py b/prettyqt/utils/datatypes.py index 9f8fa6f7a..172a48368 100644 --- a/prettyqt/utils/datatypes.py +++ b/prettyqt/utils/datatypes.py @@ -637,14 +637,10 @@ def to_marginsf(margins: MarginsFType | QtCore.QMargins | None) -> QtCore.QMargi case (int() | float() as x, int() | float() as y): return QtCore.QMarginsF(x, y, x, y) case ( - int() - | float() as left, - int() - | float() as top, - int() - | float() as right, - int() - | float() as bottom, + int() | float() as left, + int() | float() as top, + int() | float() as right, + int() | float() as bottom, ): return QtCore.QMarginsF(left, top, right, bottom) case QtCore.QMarginsF(): diff --git a/prettyqt/utils/listdelegators.py b/prettyqt/utils/listdelegators.py index e63525b7c..2d1b92bdd 100644 --- a/prettyqt/utils/listdelegators.py +++ b/prettyqt/utils/listdelegators.py @@ -20,16 +20,13 @@ def __init__(self, *args, parent=None): super().__init__(*args) @overload - def __getitem__(self, index: str) -> ListDelegator[fx.AnimationWrapper]: - ... + def __getitem__(self, index: str) -> ListDelegator[fx.AnimationWrapper]: ... @overload - def __getitem__(self, index: slice) -> ListDelegator[T]: - ... + def __getitem__(self, index: slice) -> ListDelegator[T]: ... @overload - def __getitem__(self, index: SupportsIndex) -> T: - ... + def __getitem__(self, index: SupportsIndex) -> T: ... def __getitem__( self, index: str | SupportsIndex | slice @@ -49,12 +46,10 @@ def __getitem__( return super().__getitem__(index) @overload - def __getattr__(self, method_name: Literal["fx"]) -> ListDelegator[fx.Fx]: - ... + def __getattr__(self, method_name: Literal["fx"]) -> ListDelegator[fx.Fx]: ... @overload - def __getattr__(self, method_name: str) -> Callable: - ... + def __getattr__(self, method_name: str) -> Callable: ... def __getattr__(self, method_name: str) -> ListDelegator[fx.Fx] | Callable: # method_name = helpers.to_lower_camel(method_name) diff --git a/prettyqt/utils/menurecentfiles.py b/prettyqt/utils/menurecentfiles.py index db34041ed..8fa26f65f 100644 --- a/prettyqt/utils/menurecentfiles.py +++ b/prettyqt/utils/menurecentfiles.py @@ -2,6 +2,7 @@ Application's QSettings are used to store the list of recent files. """ + from __future__ import annotations import contextlib diff --git a/prettyqt/widgets/stackedwidget.py b/prettyqt/widgets/stackedwidget.py index 359a837f2..1fe33f6ef 100644 --- a/prettyqt/widgets/stackedwidget.py +++ b/prettyqt/widgets/stackedwidget.py @@ -18,12 +18,12 @@ def __add__(self, other: widgets.QWidget) -> StackedWidget: return self @overload - def __getitem__(self, index: int) -> widgets.QWidget: - ... + def __getitem__(self, index: int) -> widgets.QWidget: ... @overload - def __getitem__(self, index: slice) -> listdelegators.ListDelegator[widgets.QWidget]: - ... + def __getitem__( + self, index: slice + ) -> listdelegators.ListDelegator[widgets.QWidget]: ... def __getitem__( self, index: int | slice diff --git a/prettyqt/widgets/tabwidget.py b/prettyqt/widgets/tabwidget.py index 20f3559db..55da81ab4 100644 --- a/prettyqt/widgets/tabwidget.py +++ b/prettyqt/widgets/tabwidget.py @@ -48,12 +48,12 @@ def __len__(self) -> int: return self.count() @overload - def __getitem__(self, index: int) -> widgets.QWidget: - ... + def __getitem__(self, index: int) -> widgets.QWidget: ... @overload - def __getitem__(self, index: slice) -> listdelegators.ListDelegator[widgets.QWidget]: - ... + def __getitem__( + self, index: slice + ) -> listdelegators.ListDelegator[widgets.QWidget]: ... def __getitem__( self, index: int | slice diff --git a/tests/conftest.py b/tests/conftest.py index 2b7478c10..adaa2ae71 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ """Tests for `datacook` package.""" + from __future__ import annotations import sys diff --git a/tests/test_gui.py b/tests/test_gui.py index cb4ce3bbf..19c7154fc 100644 --- a/tests/test_gui.py +++ b/tests/test_gui.py @@ -1,6 +1,5 @@ """Tests for `prettyqt` package.""" - import importlib.util import itertools import pathlib diff --git a/tests/test_network.py b/tests/test_network.py index 6b62ce091..38961938e 100644 --- a/tests/test_network.py +++ b/tests/test_network.py @@ -1,4 +1,5 @@ """Tests for `prettyqt` package.""" + import pytest from prettyqt import core, network diff --git a/tests/test_quick.py b/tests/test_quick.py index cf682ad99..56ad5f522 100644 --- a/tests/test_quick.py +++ b/tests/test_quick.py @@ -1,6 +1,5 @@ """Tests for `prettyqt` package.""" - import pathlib import pytest diff --git a/tests/test_quickwidgets.py b/tests/test_quickwidgets.py index 05711995c..c57015dfc 100644 --- a/tests/test_quickwidgets.py +++ b/tests/test_quickwidgets.py @@ -1,6 +1,5 @@ """Tests for `prettyqt` package.""" - import pathlib from prettyqt import quickwidgets