Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 9, 2024
1 parent d8a8b31 commit 0492c98
Show file tree
Hide file tree
Showing 27 changed files with 102 additions and 120 deletions.
22 changes: 10 additions & 12 deletions prettyqt/charts/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
6 changes: 2 additions & 4 deletions prettyqt/core/animationgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
14 changes: 6 additions & 8 deletions prettyqt/core/operatingsystemversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion prettyqt/custom_widgets/itemviews/filterheader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion prettyqt/custom_widgets/objectbrowser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Object browser GUI in Qt."""


from __future__ import annotations

import logging
Expand Down
2 changes: 1 addition & 1 deletion prettyqt/custom_widgets/scrollareatocwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
6 changes: 3 additions & 3 deletions prettyqt/debugging/package_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
4 changes: 3 additions & 1 deletion prettyqt/itemdelegates/radiodelegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
57 changes: 28 additions & 29 deletions prettyqt/itemmodels/astmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand All @@ -57,6 +55,7 @@ class AstModel(itemmodels.TreeModel):
### Example:
```py
import ast
view = TreeView()
code = pathlib.Path(__file__).read_text()
tree = ast.parse(code)
Expand Down
5 changes: 3 additions & 2 deletions prettyqt/itemmodels/proxies/changeheadersproxymodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion prettyqt/itemmodels/proxies/columnjoinerproxymodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class ColumnJoinerProxyModel(core.AbstractProxyModel):
table.set_model(model)
# table.proxifier.add_column(header="Full name", formatter="{1}, {0}")
table.show()
```
<figure markdown>
![Image title](../../images/columnjoinerproxymodel_before.png)
Expand Down
1 change: 0 additions & 1 deletion prettyqt/itemmodels/proxies/meltproxymodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class MeltProxyModel(core.AbstractProxyModel):
table.set_model(model)
# table.proxifier.melt(id_columns=[0, 1])
table.show()
```
<figure markdown>
![Image title](../../images/meltproxymodel_before.png)
Expand Down
1 change: 0 additions & 1 deletion prettyqt/itemmodels/proxies/tabletolistproxymodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class TableToListProxyModel(core.IdentityProxyModel):
table.set_model(model)
# table.proxifier.to_list()
table.show()
```
<figure markdown>
![Image title](../../images/tabletolistproxymodel_before.png)
Expand Down
7 changes: 5 additions & 2 deletions prettyqt/itemmodels/tupletreemodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions prettyqt/itemmodels/widgetsdetailsmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
26 changes: 12 additions & 14 deletions prettyqt/multimedia/audioformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
)


Expand Down
12 changes: 5 additions & 7 deletions prettyqt/positioning/geocoordinate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
12 changes: 4 additions & 8 deletions prettyqt/utils/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
15 changes: 5 additions & 10 deletions prettyqt/utils/listdelegators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions prettyqt/utils/menurecentfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Application's QSettings are used to store the list of recent files.
"""

from __future__ import annotations

import contextlib
Expand Down
8 changes: 4 additions & 4 deletions prettyqt/widgets/stackedwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions prettyqt/widgets/tabwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 0492c98

Please sign in to comment.