diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 431c20c303..6a95e18eb4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ repos: hooks: - id: isort - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.12.1 + rev: 24.1.1 hooks: - id: black language_version: python3 diff --git a/android/src/toga_android/widgets/base.py b/android/src/toga_android/widgets/base.py index 5acba9a5fb..90a05849d4 100644 --- a/android/src/toga_android/widgets/base.py +++ b/android/src/toga_android/widgets/base.py @@ -68,8 +68,7 @@ def __init__(self, interface): self.interface.style.reapply() @abstractmethod - def create(self): - ... + def create(self): ... def set_app(self, app): pass diff --git a/changes/2368.misc.rst b/changes/2368.misc.rst new file mode 100644 index 0000000000..bd8bb5d7c4 --- /dev/null +++ b/changes/2368.misc.rst @@ -0,0 +1 @@ +The ``pre-commit`` hook for ``black-pre-commit-mirror`` was updated to its latest version. diff --git a/cocoa/src/toga_cocoa/widgets/base.py b/cocoa/src/toga_cocoa/widgets/base.py index e400af7b41..28da6271fb 100644 --- a/cocoa/src/toga_cocoa/widgets/base.py +++ b/cocoa/src/toga_cocoa/widgets/base.py @@ -17,8 +17,7 @@ def __init__(self, interface): self.interface.style.reapply() @abstractmethod - def create(self): - ... + def create(self): ... def set_app(self, app): pass @@ -116,5 +115,4 @@ def refresh(self): self.rehint() @abstractmethod - def rehint(self): - ... + def rehint(self): ... diff --git a/core/src/toga/widgets/canvas.py b/core/src/toga/widgets/canvas.py index fea640b2d3..8af764942c 100644 --- a/core/src/toga/widgets/canvas.py +++ b/core/src/toga/widgets/canvas.py @@ -58,8 +58,7 @@ def __repr__(self): return f"{self.__class__.__name__}()" @abstractmethod - def _draw(self, impl, **kwargs): - ... + def _draw(self, impl, **kwargs): ... class BeginPath(DrawingObject): diff --git a/core/src/toga/widgets/optioncontainer.py b/core/src/toga/widgets/optioncontainer.py index ba3e9fa35a..601be4cada 100644 --- a/core/src/toga/widgets/optioncontainer.py +++ b/core/src/toga/widgets/optioncontainer.py @@ -270,8 +270,7 @@ def index(self, value: str | int | OptionItem): def append( self, text_or_item: OptionItem, - ): - ... + ): ... @overload def append( @@ -281,8 +280,7 @@ def append( *, icon: IconContent | None = None, enabled: bool = True, - ): - ... + ): ... def append( self, @@ -311,8 +309,7 @@ def insert( self, index: int | str | OptionItem, text_or_item: OptionItem, - ): - ... + ): ... @overload def insert( @@ -323,8 +320,7 @@ def insert( *, icon: IconContent | None = None, enabled: bool = True, - ): - ... + ): ... def insert( self, diff --git a/core/src/toga/widgets/slider.py b/core/src/toga/widgets/slider.py index 28d129af8d..98e559483f 100644 --- a/core/src/toga/widgets/slider.py +++ b/core/src/toga/widgets/slider.py @@ -318,36 +318,28 @@ def range(self, range): class SliderImpl(ABC): @abstractmethod - def get_value(self): - ... + def get_value(self): ... @abstractmethod - def set_value(self, value): - ... + def set_value(self, value): ... @abstractmethod - def get_min(self): - ... + def get_min(self): ... @abstractmethod - def set_min(self, value): - ... + def set_min(self, value): ... @abstractmethod - def get_max(self): - ... + def get_max(self): ... @abstractmethod - def set_max(self, value): - ... + def set_max(self, value): ... @abstractmethod - def get_tick_count(self): - ... + def get_tick_count(self): ... @abstractmethod - def set_tick_count(self, tick_count): - ... + def set_tick_count(self, tick_count): ... class IntSliderImpl(SliderImpl): @@ -407,21 +399,16 @@ def on_change(self): self.interface.on_change() @abstractmethod - def get_int_value(self): - ... + def get_int_value(self): ... @abstractmethod - def set_int_value(self, value): - ... + def set_int_value(self, value): ... @abstractmethod - def get_int_max(self): - ... + def get_int_max(self): ... @abstractmethod - def set_int_max(self, max): - ... + def set_int_max(self, max): ... @abstractmethod - def set_ticks_visible(self, visible): - ... + def set_ticks_visible(self, visible): ... diff --git a/core/src/toga/window.py b/core/src/toga/window.py index bfd6057f91..2304b5f45e 100644 --- a/core/src/toga/window.py +++ b/core/src/toga/window.py @@ -516,8 +516,7 @@ def stack_trace_dialog( content: str, retry: Literal[False] = False, on_result: DialogResultHandler[None] | None = None, - ) -> Dialog: - ... + ) -> Dialog: ... @overload def stack_trace_dialog( @@ -527,8 +526,7 @@ def stack_trace_dialog( content: str, retry: Literal[True] = False, on_result: DialogResultHandler[bool] | None = None, - ) -> Dialog: - ... + ) -> Dialog: ... @overload def stack_trace_dialog( @@ -538,8 +536,7 @@ def stack_trace_dialog( content: str, retry: bool = False, on_result: DialogResultHandler[bool | None] | None = None, - ) -> Dialog: - ... + ) -> Dialog: ... def stack_trace_dialog( self, @@ -632,8 +629,7 @@ def open_file_dialog( multiple_select: Literal[False] = False, on_result: DialogResultHandler[Path | None] | None = None, multiselect=None, # DEPRECATED - ) -> Dialog: - ... + ) -> Dialog: ... @overload def open_file_dialog( @@ -644,8 +640,7 @@ def open_file_dialog( multiple_select: Literal[True] = True, on_result: DialogResultHandler[list[Path] | None] | None = None, multiselect=None, # DEPRECATED - ) -> Dialog: - ... + ) -> Dialog: ... @overload def open_file_dialog( @@ -656,8 +651,7 @@ def open_file_dialog( multiple_select: bool = False, on_result: DialogResultHandler[list[Path] | Path | None] | None = None, multiselect=None, # DEPRECATED - ) -> Dialog: - ... + ) -> Dialog: ... def open_file_dialog( self, @@ -724,8 +718,7 @@ def select_folder_dialog( multiple_select: Literal[False] = False, on_result: DialogResultHandler[Path | None] | None = None, multiselect=None, # DEPRECATED - ) -> Dialog: - ... + ) -> Dialog: ... @overload def select_folder_dialog( @@ -735,8 +728,7 @@ def select_folder_dialog( multiple_select: Literal[True] = True, on_result: DialogResultHandler[list[Path] | None] | None = None, multiselect=None, # DEPRECATED - ) -> Dialog: - ... + ) -> Dialog: ... @overload def select_folder_dialog( @@ -746,8 +738,7 @@ def select_folder_dialog( multiple_select: bool = False, on_result: DialogResultHandler[list[Path] | Path | None] | None = None, multiselect=None, # DEPRECATED - ) -> Dialog: - ... + ) -> Dialog: ... def select_folder_dialog( self, diff --git a/core/tests/widgets/test_progressbar.py b/core/tests/widgets/test_progressbar.py index b35287e3c0..9b82f80511 100644 --- a/core/tests/widgets/test_progressbar.py +++ b/core/tests/widgets/test_progressbar.py @@ -103,9 +103,11 @@ def test_set_max(progressbar, value, actual, determinate): ( object(), TypeError, - r"must be a string or a number" - if sys.version_info < (3, 10) - else r"must be a string or a real number", + ( + r"must be a string or a number" + if sys.version_info < (3, 10) + else r"must be a string or a real number" + ), ), # Non-coercible to float ( -42, diff --git a/examples/optioncontainer/optioncontainer/app.py b/examples/optioncontainer/optioncontainer/app.py index bc6de7add0..052c397b47 100644 --- a/examples/optioncontainer/optioncontainer/app.py +++ b/examples/optioncontainer/optioncontainer/app.py @@ -39,9 +39,9 @@ def on_insert_option(self, button): def on_enable_option(self, button): index = int(self.select_option.value) try: - self.optioncontainer.content[ - index - ].enabled = not self.optioncontainer.content[index].enabled + self.optioncontainer.content[index].enabled = ( + not self.optioncontainer.content[index].enabled + ) except ValueError as e: self.main_window.info_dialog("Oops", str(e)) diff --git a/examples/positron-django/src/webapp/urls.py b/examples/positron-django/src/webapp/urls.py index f8bd49391d..df2c234804 100644 --- a/examples/positron-django/src/webapp/urls.py +++ b/examples/positron-django/src/webapp/urls.py @@ -13,6 +13,7 @@ 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ + from django.contrib import admin from django.urls import path diff --git a/gtk/src/toga_gtk/app.py b/gtk/src/toga_gtk/app.py index 4d01f4e6ff..d85db4e896 100644 --- a/gtk/src/toga_gtk/app.py +++ b/gtk/src/toga_gtk/app.py @@ -268,9 +268,9 @@ def gtk_startup(self, data=None): m.open_file_dialog( self.interface.formal_name, file_types=self.interface.document_types.keys(), - on_result=lambda dialog, path: self.interface._open(path) - if path - else self.exit(), + on_result=lambda dialog, path: ( + self.interface._open(path) if path else self.exit() + ), ) def open_file(self, widget, **kwargs): diff --git a/gtk/src/toga_gtk/widgets/base.py b/gtk/src/toga_gtk/widgets/base.py index 100a6075d8..d397d25eeb 100644 --- a/gtk/src/toga_gtk/widgets/base.py +++ b/gtk/src/toga_gtk/widgets/base.py @@ -28,8 +28,7 @@ def __init__(self, interface): self.interface.style.reapply() @abstractmethod - def create(self): - ... + def create(self): ... def set_app(self, app): pass diff --git a/gtk/src/toga_gtk/widgets/scrollcontainer.py b/gtk/src/toga_gtk/widgets/scrollcontainer.py index 914ab7087b..ce13d9fa29 100644 --- a/gtk/src/toga_gtk/widgets/scrollcontainer.py +++ b/gtk/src/toga_gtk/widgets/scrollcontainer.py @@ -47,9 +47,11 @@ def get_horizontal(self): def set_horizontal(self, value): self.native.set_policy( Gtk.PolicyType.AUTOMATIC if value else Gtk.PolicyType.NEVER, - Gtk.PolicyType.AUTOMATIC - if self.interface.vertical - else Gtk.PolicyType.NEVER, + ( + Gtk.PolicyType.AUTOMATIC + if self.interface.vertical + else Gtk.PolicyType.NEVER + ), ) # Disabling scrolling implies a position reset; that's a scroll event. if not value: @@ -61,9 +63,11 @@ def get_vertical(self): def set_vertical(self, value): self.native.set_policy( - Gtk.PolicyType.AUTOMATIC - if self.interface.horizontal - else Gtk.PolicyType.NEVER, + ( + Gtk.PolicyType.AUTOMATIC + if self.interface.horizontal + else Gtk.PolicyType.NEVER + ), Gtk.PolicyType.AUTOMATIC if value else Gtk.PolicyType.NEVER, ) # Disabling scrolling implies a position reset; that's a scroll event. diff --git a/iOS/src/toga_iOS/dialogs.py b/iOS/src/toga_iOS/dialogs.py index 137a1de1ce..caf15fa793 100644 --- a/iOS/src/toga_iOS/dialogs.py +++ b/iOS/src/toga_iOS/dialogs.py @@ -33,8 +33,7 @@ def __init__(self, interface, title, message): ) @abstractmethod - def populate_dialog(self, native): - ... + def populate_dialog(self, native): ... def response(self, value): self.interface.set_result(value) diff --git a/iOS/src/toga_iOS/widgets/base.py b/iOS/src/toga_iOS/widgets/base.py index c14513dfe4..59cb4f241b 100644 --- a/iOS/src/toga_iOS/widgets/base.py +++ b/iOS/src/toga_iOS/widgets/base.py @@ -17,8 +17,7 @@ def __init__(self, interface): self.interface.style.reapply() @abstractmethod - def create(self): - ... + def create(self): ... def set_app(self, app): pass @@ -123,5 +122,4 @@ def refresh(self): self.rehint() @abstractmethod - def rehint(self): - ... + def rehint(self): ... diff --git a/iOS/src/toga_iOS/widgets/detailedlist.py b/iOS/src/toga_iOS/widgets/detailedlist.py index 6212de3504..c124c65068 100644 --- a/iOS/src/toga_iOS/widgets/detailedlist.py +++ b/iOS/src/toga_iOS/widgets/detailedlist.py @@ -86,9 +86,11 @@ def tableView_trailingSwipeActionsConfigurationForRowAtIndexPath_( if self.impl.primary_action_enabled: actions = [ UIContextualAction.contextualActionWithStyle( - UIContextualActionStyle.Destructive - if self.interface._primary_action in self.impl.DESTRUCTIVE_NAMES - else UIContextualActionStyle.Normal, + ( + UIContextualActionStyle.Destructive + if self.interface._primary_action in self.impl.DESTRUCTIVE_NAMES + else UIContextualActionStyle.Normal + ), title=self.interface._primary_action, handler=self.impl.primary_action_handler(indexPath.row), ) @@ -105,9 +107,12 @@ def tableView_leadingSwipeActionsConfigurationForRowAtIndexPath_( if self.impl.secondary_action_enabled: actions = [ UIContextualAction.contextualActionWithStyle( - UIContextualActionStyle.Destructive - if self.interface._secondary_action in self.impl.DESTRUCTIVE_NAMES - else UIContextualActionStyle.Normal, + ( + UIContextualActionStyle.Destructive + if self.interface._secondary_action + in self.impl.DESTRUCTIVE_NAMES + else UIContextualActionStyle.Normal + ), title=self.interface._secondary_action, handler=self.impl.secondary_action_handler(indexPath.row), ) diff --git a/testbed/tests/widgets/test_table.py b/testbed/tests/widgets/test_table.py index 10752e90a5..91e684268c 100644 --- a/testbed/tests/widgets/test_table.py +++ b/testbed/tests/widgets/test_table.py @@ -477,9 +477,11 @@ async def test_cell_widget(widget, probe): "a": f"A{i}", "b": f"B{i}", # Toga widgets. - "c": toga.Button(f"C{i}") - if i % 2 == 0 - else toga.TextInput(value=f"edit C{i}"), + "c": ( + toga.Button(f"C{i}") + if i % 2 == 0 + else toga.TextInput(value=f"edit C{i}") + ), } for i in range(0, 50) ] diff --git a/testbed/tests/widgets/test_tree.py b/testbed/tests/widgets/test_tree.py index 19555bc9bf..4899d9fa2c 100644 --- a/testbed/tests/widgets/test_tree.py +++ b/testbed/tests/widgets/test_tree.py @@ -660,9 +660,11 @@ async def test_cell_widget(widget, probe): "a": f"A{i}", "b": f"B{i}", # Toga widgets. - "c": toga.Button(f"C{i}") - if i % 2 == 0 - else toga.TextInput(value=f"edit C{i}"), + "c": ( + toga.Button(f"C{i}") + if i % 2 == 0 + else toga.TextInput(value=f"edit C{i}") + ), }, None, ) diff --git a/winforms/src/toga_winforms/widgets/base.py b/winforms/src/toga_winforms/widgets/base.py index c966dfd219..123c98f257 100644 --- a/winforms/src/toga_winforms/widgets/base.py +++ b/winforms/src/toga_winforms/widgets/base.py @@ -53,8 +53,7 @@ def __init__(self, interface): self.interface.style.reapply() @abstractmethod - def create(self): - ... + def create(self): ... def set_app(self, app): # No special handling required