diff --git a/android/src/toga_android/app.py b/android/src/toga_android/app.py index ff5dc08910..4c4e62a26e 100644 --- a/android/src/toga_android/app.py +++ b/android/src/toga_android/app.py @@ -327,6 +327,10 @@ def set_current_window(self, window): # Platform-specific APIs ###################################################################### + ###################################################################### + # 2024-2: Backwards compatibility for < 0.4.1 + ###################################################################### + async def intent_result(self, intent): # pragma: no cover warnings.warn( "intent_result has been deprecated; use start_activity", @@ -345,6 +349,10 @@ def complete_handler(code, data): except AttributeError: raise RuntimeError("No appropriate Activity found to handle this intent.") + ###################################################################### + # End backwards compatibility + ###################################################################### + def _native_startActivityForResult( self, activity, code, *options ): # pragma: no cover diff --git a/changes/3059.removal.rst b/changes/3059.removal.rst new file mode 100644 index 0000000000..79b9234250 --- /dev/null +++ b/changes/3059.removal.rst @@ -0,0 +1 @@ +Deprecations from 0.4.0 and earlier have been removed. diff --git a/cocoa/src/toga_cocoa/libs/appkit.py b/cocoa/src/toga_cocoa/libs/appkit.py index 15cb62662b..921eb452c0 100644 --- a/cocoa/src/toga_cocoa/libs/appkit.py +++ b/cocoa/src/toga_cocoa/libs/appkit.py @@ -626,9 +626,7 @@ class NSLineBreakMode(Enum): NSStringDrawingUsesLineFragmentOrigin = 1 << 0 NSStringDrawingUsesFontLeading = 1 << 1 -NSStringDrawingDisableScreenFontSubstitution = 1 << 2 # DEPRECATED NSStringDrawingUsesDeviceMetrics = 1 << 3 -NSStringDrawingOneShot = 1 << 4 # DEPRECATED NSStringDrawingTruncatesLastVisibleLine = 1 << 5 ###################################################################### diff --git a/core/src/toga/app.py b/core/src/toga/app.py index aca728de74..421a8370d2 100644 --- a/core/src/toga/app.py +++ b/core/src/toga/app.py @@ -162,8 +162,6 @@ def __init__( document_types: list[type[Document]] | None = None, on_running: OnRunningHandler | None = None, on_exit: OnExitHandler | None = None, - id: None = None, # DEPRECATED - windows: None = None, # DEPRECATED ): """Create a new App instance. @@ -201,30 +199,7 @@ def __init__( :param on_exit: The initial :any:`on_exit` handler. :param document_types: A list of :any:`Document` classes that this app can manage. - :param id: **DEPRECATED** - This argument will be ignored. If you need a - machine-friendly identifier, use ``app_id``. - :param windows: **DEPRECATED** – Windows are now automatically added to the - current app. Passing this argument will cause an exception. """ - ###################################################################### - # 2023-10: Backwards compatibility - ###################################################################### - if id is not None: - warnings.warn( - "App.id is deprecated and will be ignored. Use app_id instead", - DeprecationWarning, - stacklevel=2, - ) - - if windows is not None: - raise ValueError( - "The `windows` constructor argument of toga.App has been removed. " - "Windows are now automatically added to the current app." - ) - ###################################################################### - # End backwards compatibility - ###################################################################### - # Initialize empty widgets registry self._widgets = WidgetRegistry() @@ -418,14 +393,6 @@ def icon(self, icon_or_name: IconContentT) -> None: # so that the app instance can be instantiated with the correct icon. pass - @property - def id(self) -> str: - """**DEPRECATED** – Use :any:`app_id`.""" - warnings.warn( - "App.id is deprecated. Use app_id instead", DeprecationWarning, stacklevel=2 - ) - return self._app_id - @property def version(self) -> str | None: """The version number of the app (read-only).""" @@ -936,27 +903,7 @@ def on_running(self) -> None: """ ###################################################################### - # 2023-10: Backwards compatibility - ###################################################################### - - @property - def name(self) -> str: - """**DEPRECATED** – Use :any:`formal_name`.""" - warnings.warn( - "App.name is deprecated. Use formal_name instead", - DeprecationWarning, - stacklevel=2, - ) - return self._formal_name - - # Support WindowSet __iadd__ and __isub__ - @windows.setter - def windows(self, windows: WindowSet) -> None: - if windows is not self._windows: - raise AttributeError("can't set attribute 'windows'") - - ###################################################################### - # 2024-06: Backwards compatibility + # 2024-06: Backwards compatibility for <= 0.4.5 ###################################################################### def add_background_task(self, handler: BackgroundTask) -> None: @@ -972,7 +919,7 @@ def add_background_task(self, handler: BackgroundTask) -> None: self.loop.call_soon_threadsafe(wrapped_handler(self, handler)) ###################################################################### - # 2024-07: Backwards compatibility + # 2024-12: Backwards compatibility for <= 0.4.8 ###################################################################### def exit_full_screen(self) -> None: @@ -1022,7 +969,7 @@ def set_full_screen(self, *windows: Window) -> None: ###################################################################### -# 2024-08: Backwards compatibility +# 2024-08: Backwards compatibility for <= 0.4.5 ###################################################################### diff --git a/core/src/toga/handlers.py b/core/src/toga/handlers.py index 4b5764578f..4afdead646 100644 --- a/core/src/toga/handlers.py +++ b/core/src/toga/handlers.py @@ -196,7 +196,7 @@ def __init__(self, on_result: OnResultT | None = None) -> None: self.future = loop.create_future() ###################################################################### - # 2023-12: Backwards compatibility + # 2023-12: Backwards compatibility for <= 0.4.0 ###################################################################### self.on_result: OnResultT | None if on_result: diff --git a/core/src/toga/icons.py b/core/src/toga/icons.py index 25e21970a7..42dd9e9793 100644 --- a/core/src/toga/icons.py +++ b/core/src/toga/icons.py @@ -1,7 +1,6 @@ from __future__ import annotations import sys -import warnings from collections.abc import Callable, Iterable from pathlib import Path from typing import TYPE_CHECKING @@ -43,16 +42,6 @@ def __get__(self, obj: object, owner: type[Icon]) -> Icon: class Icon: - @cachedicon - def TOGA_ICON(cls) -> Icon: - """**DEPRECATED** - Use ``DEFAULT_ICON``, or your own icon.""" - warnings.warn( - "TOGA_ICON has been deprecated; Use DEFAULT_ICON, or your own icon.", - DeprecationWarning, - ) - - return Icon("toga", system=True) - @cachedicon def APP_ICON(cls) -> Icon: """The application icon. diff --git a/core/src/toga/images.py b/core/src/toga/images.py index 5f891b3624..f2c11de3fd 100644 --- a/core/src/toga/images.py +++ b/core/src/toga/images.py @@ -92,7 +92,7 @@ def __init__( :raises ValueError: If the source cannot be loaded as an image. """ ###################################################################### - # 2023-11: Backwards compatibility + # 2023-11: Backwards compatibility for <= 0.4.0 ###################################################################### num_provided = sum(arg is not NOT_PROVIDED for arg in (src, path, data)) if num_provided > 1: diff --git a/core/src/toga/style/applicator.py b/core/src/toga/style/applicator.py index da4a81c537..a6a81a34e1 100644 --- a/core/src/toga/style/applicator.py +++ b/core/src/toga/style/applicator.py @@ -13,6 +13,10 @@ class TogaApplicator: """Apply styles to a Toga widget.""" + ###################################################################### + # 2024-12: Backwards compatibility for <= 0.4.8 + ###################################################################### + def __init__(self, widget: None = None): if widget is not None: warnings.warn( @@ -22,6 +26,10 @@ def __init__(self, widget: None = None): stacklevel=2, ) + ###################################################################### + # End backwards compatibility + ###################################################################### + @property def widget(self) -> Widget: """The widget to which this applicator is assigned. diff --git a/core/src/toga/style/pack.py b/core/src/toga/style/pack.py index 1b353fd21b..0932fc21f6 100644 --- a/core/src/toga/style/pack.py +++ b/core/src/toga/style/pack.py @@ -107,9 +107,9 @@ def _hidden(self) -> bool: """Does this style declaration define an object that should be hidden.""" return self.visibility == HIDDEN - ####################################################### - # Backwards compatibility for Toga <= 0.4.8 - ####################################################### + ###################################################################### + # 2024-12: Backwards compatibility for Toga <= 0.4.8 + ###################################################################### def update(self, **properties): properties = { @@ -243,9 +243,9 @@ def __delitem__(self, name): return super().__delitem__(self._update_property_name(name.replace("-", "_"))) - ####################################################### + ###################################################################### # End backwards compatibility - ####################################################### + ###################################################################### def apply(self, prop: str, value: object) -> None: if self._applicator: diff --git a/core/src/toga/widgets/base.py b/core/src/toga/widgets/base.py index 0d179ac8ac..1df9d789c5 100644 --- a/core/src/toga/widgets/base.py +++ b/core/src/toga/widgets/base.py @@ -43,9 +43,9 @@ def __init__( # Get factory and assign implementation self.factory = get_platform_factory() - ########################################### - # Backwards compatibility for Toga <= 0.4.8 - ########################################### + #################################################### + # 2024-12: Backwards compatibility for Toga <= 0.4.8 + #################################################### # Just in case we're working with a third-party widget created before # the _create() mechanism was added, which has already defined its diff --git a/core/src/toga/widgets/canvas/canvas.py b/core/src/toga/widgets/canvas/canvas.py index 45f5fd5ac2..0eb4f7e778 100644 --- a/core/src/toga/widgets/canvas/canvas.py +++ b/core/src/toga/widgets/canvas/canvas.py @@ -1,7 +1,5 @@ from __future__ import annotations -import warnings -from math import pi from typing import ( TYPE_CHECKING, Any, @@ -297,7 +295,6 @@ def measure_text( self, text: str, font: Font | None = None, - tight: None = None, # DEPRECATED ) -> tuple[float, float]: """Measure the size at which :meth:`~.Context.write_text` would render some text. @@ -305,14 +302,8 @@ def measure_text( :param text: The text to measure. Newlines will cause line breaks, but long lines will not be wrapped. :param font: The font in which to draw the text. The default is the system font. - :param tight: **DEPRECATED**: this argument has no effect. :returns: A tuple of ``(width, height)``. """ - if tight is not None: - warnings.warn( - "The `tight` argument on Canvas.measure_text() has been deprecated.", - DeprecationWarning, - ) if font is None: font = Font(family=SYSTEM, size=SYSTEM_DEFAULT_FONT_SIZE) @@ -328,185 +319,3 @@ def as_image(self, format: type[ImageT] = toga.Image) -> ImageT: :returns: The canvas as an image of the specified type. """ return toga.Image(self._impl.get_image_data()).as_format(format) - - ########################################################################### - # 2023-07 Backwards compatibility - ########################################################################### - - def new_path(self): - """**DEPRECATED** - Use :meth:`~toga.widgets.canvas.Context.begin_path` on - :attr:`context`""" - warnings.warn( - "Direct canvas operations have been deprecated; use context.begin_path()", - DeprecationWarning, - ) - return self.context.begin_path() - - def move_to(self, x, y): - """**DEPRECATED** - Use :meth:`~toga.widgets.canvas.Context.move_to` on - :attr:`context`""" - warnings.warn( - "Direct canvas operations have been deprecated; use context.move_to()", - DeprecationWarning, - ) - return self.context.move_to(x, y) - - def line_to(self, x, y): - """**DEPRECATED** - Use :meth:`~toga.widgets.canvas.Context.line_to` on - :attr:`context`""" - warnings.warn( - "Direct canvas operations have been deprecated; use context.line_to()", - DeprecationWarning, - ) - return self.context.line_to(x, y) - - def bezier_curve_to(self, cp1x, cp1y, cp2x, cp2y, x, y): - """**DEPRECATED** - Use :meth:`~toga.widgets.canvas.Context.bezier_curve_to` on - :attr:`context`""" - warnings.warn( - "Direct canvas operations have been deprecated; " - "use context.bezier_curve_to()", - DeprecationWarning, - ) - return self.context.bezier_curve_to(cp1x, cp1y, cp2x, cp2y, x, y) - - def quadratic_curve_to(self, cpx: float, cpy: float, x: float, y: float): - """**DEPRECATED** - Use :meth:`~toga.widgets.canvas.Context.quadratic_curve_to` - on :attr:`context`""" - warnings.warn( - "Direct canvas operations have been deprecated; " - "use context.quadratic_curve_to()", - DeprecationWarning, - ) - return self.context.quadratic_curve_to(cpx, cpy, x, y) - - def arc(self, x, y, radius, startangle=0.0, endangle=2 * pi, anticlockwise=False): - """**DEPRECATED** - Use :meth:`~toga.widgets.canvas.Context.arc` on - :attr:`context`""" - warnings.warn( - "Direct canvas operations have been deprecated; use context.arc()", - DeprecationWarning, - ) - return self.context.arc(x, y, radius, startangle, endangle, anticlockwise) - - def ellipse( - self, - x: float, - y: float, - radiusx: float, - radiusy: float, - rotation: float = 0.0, - startangle: float = 0.0, - endangle: float = 2 * pi, - anticlockwise: bool = False, - ): - """**DEPRECATED** - Use :meth:`~toga.widgets.canvas.Context.ellipse` on - :attr:`context`""" - warnings.warn( - "Direct canvas operations have been deprecated; use context.ellipse()", - DeprecationWarning, - ) - return self.context.ellipse( - x, - y, - radiusx, - radiusy, - rotation, - startangle, - endangle, - anticlockwise, - ) - - def rect(self, x: float, y: float, width: float, height: float): - """**DEPRECATED** - Use :meth:`~toga.widgets.canvas.Context.rect` on - :attr:`context`""" - warnings.warn( - "Direct canvas operations have been deprecated; use context.rect()", - DeprecationWarning, - ) - return self.context.rect(x, y, width, height) - - def write_text(self, text: str, x=0, y=0, font=None): - """**DEPRECATED** - Use :meth:`~toga.widgets.canvas.Context.write_text` on - :attr:`context`""" - warnings.warn( - "Direct canvas operations have been deprecated; use context.write_text()", - DeprecationWarning, - ) - return self.context.write_text(text, x, y, font) - - def rotate(self, radians: float): - """**DEPRECATED** - Use :meth:`~toga.widgets.canvas.Context.rotate` on - :attr:`context`""" - warnings.warn( - "Direct canvas operations have been deprecated; use context.rotate()", - DeprecationWarning, - ) - return self.context.rotate(radians) - - def scale(self, sx: float, sy: float): - """**DEPRECATED** - Use :meth:`~toga.widgets.canvas.Context.scale` - on :attr:`context`""" - warnings.warn( - "Direct canvas operations have been deprecated; use context.scale()", - DeprecationWarning, - ) - return self.context.scale(sx, sy) - - def translate(self, tx: float, ty: float): - """**DEPRECATED** - Use :meth:`~toga.widgets.canvas.Context.translate` on - :attr:`context`""" - warnings.warn( - "Direct canvas operations have been deprecated; use context.translate()", - DeprecationWarning, - ) - return self.context.translate(tx, ty) - - def reset_transform(self): - """**DEPRECATED** - Use :meth:`~toga.widgets.canvas.Context.reset_transform` on - :attr:`context`""" - warnings.warn( - "Direct canvas operations have been deprecated; " - "use context.reset_transform()", - DeprecationWarning, - ) - return self.context.reset_transform() - - def closed_path(self, x, y): - """**DEPRECATED** - use :meth:`~toga.Canvas.ClosedPath`""" - warnings.warn( - "Canvas.closed_path() has been renamed Canvas.ClosedPath()", - DeprecationWarning, - ) - return self.ClosedPath(x, y) - - def fill( - self, - color: Color | str | None = BLACK, - fill_rule: FillRule = FillRule.NONZERO, - preserve=None, # DEPRECATED - ): - """**DEPRECATED** - use :meth:`~toga.Canvas.Fill`""" - warnings.warn( - "Canvas.fill() has been renamed Canvas.Fill()", - DeprecationWarning, - ) - if preserve is not None: - warnings.warn( - "The `preserve` argument on fill() has been deprecated.", - DeprecationWarning, - ) - return self.Fill(color=color, fill_rule=fill_rule) - - def stroke( - self, - color: Color | str | None = BLACK, - line_width: float = 2.0, - line_dash: list[float] | None = None, - ): - """**DEPRECATED** - use :meth:`~toga.Canvas.Stroke`""" - warnings.warn( - "Canvas.stroke() has been renamed Canvas.Stroke().", - DeprecationWarning, - ) - return self.Stroke(color=color, line_width=line_width, line_dash=line_dash) diff --git a/core/src/toga/widgets/canvas/context.py b/core/src/toga/widgets/canvas/context.py index 072af406b3..f779795149 100644 --- a/core/src/toga/widgets/canvas/context.py +++ b/core/src/toga/widgets/canvas/context.py @@ -1,6 +1,5 @@ from __future__ import annotations -import warnings from collections.abc import Iterator from contextlib import contextmanager from math import pi @@ -303,7 +302,6 @@ def fill( self, color: str = BLACK, fill_rule: FillRule = FillRule.NONZERO, - preserve: None = None, # DEPRECATED ) -> Fill: """Fill the current path. @@ -314,15 +312,8 @@ def fill( :param fill_rule: `nonzero` is the non-zero winding rule; `evenodd` is the even-odd winding rule. :param color: The fill color. - :param preserve: **DEPRECATED**: this argument has no effect. :returns: The ``Fill`` :any:`DrawingObject` for the operation. """ - if preserve is not None: - warnings.warn( - "The `preserve` argument on fill() has been deprecated.", - DeprecationWarning, - ) - fill = Fill(color, fill_rule) self.append(fill) return fill @@ -539,33 +530,6 @@ def Stroke( self.append(stroke) yield stroke - ########################################################################### - # 2023-07 Backwards incompatibility - ########################################################################### - - def new_path(self) -> BeginPath: - """**DEPRECATED** - Use :meth:`~toga.widgets.canvas.Context.begin_path`.""" - warnings.warn( - "Context.new_path() has been renamed Context.begin_path()", - DeprecationWarning, - ) - return self.begin_path() - - def context(self): - """**DEPRECATED** - use :meth:`~toga.widgets.canvas.Context.Context`""" - warnings.warn( - "Context.context() has been renamed Context.Context()", DeprecationWarning - ) - return self.Context() - - def closed_path(self, x: float, y: float): - """**DEPRECATED** - use :meth:`~toga.widgets.canvas.Context.ClosedPath`""" - warnings.warn( - "Context.closed_path() has been renamed Context.ClosedPath()", - DeprecationWarning, - ) - return self.ClosedPath(x, y) - class ClosedPathContext(Context): """A drawing context that will build a closed path, starting from an diff --git a/core/src/toga/widgets/canvas/drawingobject.py b/core/src/toga/widgets/canvas/drawingobject.py index cc986bdba2..69c5457f8e 100644 --- a/core/src/toga/widgets/canvas/drawingobject.py +++ b/core/src/toga/widgets/canvas/drawingobject.py @@ -2,7 +2,7 @@ from abc import ABC, abstractmethod from math import pi -from typing import Any, NoReturn +from typing import Any from travertino.colors import Color @@ -100,20 +100,6 @@ def color(self, value: Color | str | None) -> None: else: self._color = parse_color(value) - ########################################################################### - # 2023-07 Backwards incompatibility - ########################################################################### - - # `context.fill()` used to be a context manager, but is now a primitive. - # If you try to use the Fill drawing object as a context, raise an exception. - def __enter__(self) -> NoReturn: - raise RuntimeError("Context.fill() has been renamed Context.Fill().") - - def __exit__(self) -> None: # pragma: no cover - # This method is required to make the object a context manager, but as the - # __enter__ method raises an exception, the __exit__ can't be called. - pass - class Stroke(DrawingObject): def __init__( @@ -163,20 +149,6 @@ def line_dash(self) -> list[float] | None: def line_dash(self, value: list[float] | None) -> None: self._line_dash = value - ########################################################################### - # 2023-07 Backwards incompatibility - ########################################################################### - - # `context.stroke()` used to be a context manager, but is now a primitive. - # If you try to use the Stroke drawing object as a context, raise an exception. - def __enter__(self) -> NoReturn: - raise RuntimeError("Context.stroke() has been renamed Context.Stroke().") - - def __exit__(self) -> None: # pragma: no cover - # This method is required to make the object a context manager, but as the - # __enter__ method raises an exception, the __exit__ can't be called. - pass - class MoveTo(DrawingObject): def __init__(self, x: float, y: float): diff --git a/core/src/toga/widgets/dateinput.py b/core/src/toga/widgets/dateinput.py index 615a73e411..ad15c2ce82 100644 --- a/core/src/toga/widgets/dateinput.py +++ b/core/src/toga/widgets/dateinput.py @@ -1,7 +1,6 @@ from __future__ import annotations import datetime -import warnings from typing import Any, Protocol import toga @@ -162,54 +161,3 @@ def on_change(self) -> OnChangeHandler: @on_change.setter def on_change(self, handler: toga.widgets.dateinput.OnChangeHandler) -> None: self._on_change = wrapped_handler(self, handler) - - -# 2023-05: Backwards compatibility -class DatePicker(DateInput): - def __init__(self, *args: Any, **kwargs: Any): - warnings.warn("DatePicker has been renamed DateInput.", DeprecationWarning) - - for old_name, new_name in [ - ("min_date", "min"), - ("max_date", "max"), - ]: - try: - value = kwargs.pop(old_name) - warnings.warn( - f"DatePicker.{old_name} has been renamed DateInput.{new_name}", - DeprecationWarning, - ) - except KeyError: - pass - else: - kwargs[new_name] = value - - super().__init__(*args, **kwargs) - - @property - def min_date(self) -> datetime.date: - warnings.warn( - "DatePicker.min_date has been renamed DateInput.min", DeprecationWarning - ) - return self.min - - @min_date.setter - def min_date(self, value: object) -> None: - warnings.warn( - "DatePicker.min_date has been renamed DateInput.min", DeprecationWarning - ) - self.min = value - - @property - def max_date(self) -> datetime.date: - warnings.warn( - "DatePicker.max_date has been renamed DateInput.max", DeprecationWarning - ) - return self.max - - @max_date.setter - def max_date(self, value: object) -> None: - warnings.warn( - "DatePicker.max_date has been renamed DateInput.max", DeprecationWarning - ) - self.max = value diff --git a/core/src/toga/widgets/detailedlist.py b/core/src/toga/widgets/detailedlist.py index e12ffb8067..34b6bd57aa 100644 --- a/core/src/toga/widgets/detailedlist.py +++ b/core/src/toga/widgets/detailedlist.py @@ -1,6 +1,5 @@ from __future__ import annotations -import warnings from collections.abc import Iterable from typing import Any, Literal, Protocol, TypeVar @@ -65,7 +64,6 @@ def __init__( on_secondary_action: OnSecondaryActionHandler | None = None, on_refresh: OnRefreshHandler | None = None, on_select: toga.widgets.detailedlist.OnSelectHandler | None = None, - on_delete: None = None, # DEPRECATED ): """Create a new DetailedList widget. @@ -83,7 +81,6 @@ def __init__( :param secondary_action: The name for the secondary action. :param on_secondary_action: Initial :any:`on_secondary_action` handler. :param on_refresh: Initial :any:`on_refresh` handler. - :param on_delete: **DEPRECATED**; use ``on_primary_action``. """ # Prime the attributes and handlers that need to exist when the widget is # created. @@ -97,23 +94,6 @@ def __init__( super().__init__(id=id, style=style) - ###################################################################### - # 2023-06: Backwards compatibility - ###################################################################### - if on_delete: - if on_primary_action: - raise ValueError("Cannot specify both on_delete and on_primary_action") - else: - warnings.warn( - "DetailedList.on_delete has been renamed " - "DetailedList.on_primary_action.", - DeprecationWarning, - ) - on_primary_action = on_delete - ###################################################################### - # End backwards compatibility. - ###################################################################### - self.data = data self.on_primary_action = on_primary_action self.on_secondary_action = on_secondary_action @@ -272,24 +252,3 @@ def on_select(self) -> OnSelectHandler: @on_select.setter def on_select(self, handler: toga.widgets.detailedlist.OnSelectHandler) -> None: self._on_select = wrapped_handler(self, handler) - - ###################################################################### - # 2023-06: Backwards compatibility - ###################################################################### - - @property - def on_delete(self) -> OnPrimaryActionHandler: - """**DEPRECATED**; Use :any:`on_primary_action`""" - warnings.warn( - "DetailedList.on_delete has been renamed DetailedList.on_primary_action.", - DeprecationWarning, - ) - return self.on_primary_action - - @on_delete.setter - def on_delete(self, handler: OnPrimaryActionHandler) -> None: - warnings.warn( - "DetailedList.on_delete has been renamed DetailedList.on_primary_action.", - DeprecationWarning, - ) - self.on_primary_action = handler diff --git a/core/src/toga/widgets/numberinput.py b/core/src/toga/widgets/numberinput.py index 4dccb85cec..318da052ce 100644 --- a/core/src/toga/widgets/numberinput.py +++ b/core/src/toga/widgets/numberinput.py @@ -2,7 +2,6 @@ import re import sys -import warnings from decimal import ROUND_HALF_UP, Decimal, InvalidOperation from typing import TYPE_CHECKING, Any, Protocol, Union @@ -92,8 +91,6 @@ def __init__( value: NumberInputT | None = None, readonly: bool = False, on_change: toga.widgets.numberinput.OnChangeHandler | None = None, - min_value: None = None, # DEPRECATED - max_value: None = None, # DEPRECATED ): """Create a new number input widget. @@ -110,36 +107,9 @@ def __init__( :param readonly: Can the value of the widget be modified by the user? :param on_change: A handler that will be invoked when the value of the widget changes. - :param min_value: **DEPRECATED**; alias of ``min``. - :param max_value: **DEPRECATED**; alias of ``max``. """ super().__init__(id=id, style=style) - ###################################################################### - # 2023-06: Backwards compatibility - ###################################################################### - if min_value is not None: - if min is not None: - raise ValueError("Cannot specify both min and min_value") - else: - warnings.warn( - "NumberInput.min_value has been renamed NumberInput.min", - DeprecationWarning, - ) - min = min_value - if max_value is not None: - if max is not None: - raise ValueError("Cannot specify both max and max_value") - else: - warnings.warn( - "NumberInput.max_value has been renamed NumberInput.max", - DeprecationWarning, - ) - max = max_value - ###################################################################### - # End backwards compatibility - ###################################################################### - # The initial setting of min requires calling get_value(), # which in turn interrogates min. Prime those values with # an empty starting value @@ -310,41 +280,3 @@ def on_change(self) -> OnChangeHandler: @on_change.setter def on_change(self, handler: toga.widgets.numberinput.OnChangeHandler) -> None: self._on_change = wrapped_handler(self, handler) - - ###################################################################### - # 2023-06: Backwards compatibility - ###################################################################### - - @property - def min_value(self) -> Decimal | None: - """**DEPRECATED**; alias of :attr:`min`.""" - warnings.warn( - "NumberInput.min_value has been renamed NumberInput.min", - DeprecationWarning, - ) - return self.min - - @min_value.setter - def min_value(self, value: NumberInputT | None) -> None: - warnings.warn( - "NumberInput.min_value has been renamed NumberInput.min", - DeprecationWarning, - ) - self.min = value - - @property - def max_value(self) -> Decimal | None: - """**DEPRECATED**; alias of :attr:`max`.""" - warnings.warn( - "NumberInput.max_value has been renamed NumberInput.max", - DeprecationWarning, - ) - return self.max - - @max_value.setter - def max_value(self, value: NumberInputT | None) -> None: - warnings.warn( - "NumberInput.max_value has been renamed NumberInput.max", - DeprecationWarning, - ) - self.max = value diff --git a/core/src/toga/widgets/selection.py b/core/src/toga/widgets/selection.py index 657fc6e4e5..171975460f 100644 --- a/core/src/toga/widgets/selection.py +++ b/core/src/toga/widgets/selection.py @@ -1,6 +1,5 @@ from __future__ import annotations -import warnings from collections.abc import Iterable from typing import Any, Protocol, TypeVar @@ -32,7 +31,6 @@ def __init__( value: object | None = None, on_change: toga.widgets.selection.OnChangeHandler | None = None, enabled: bool = True, - on_select: None = None, # DEPRECATED ): """Create a new Selection widget. @@ -50,22 +48,6 @@ def __init__( """ super().__init__(id=id, style=style) - ###################################################################### - # 2023-05: Backwards compatibility - ###################################################################### - if on_select: # pragma: no cover - if on_change: - raise ValueError("Cannot specify both on_select and on_change") - else: - warnings.warn( - "Selection.on_select has been renamed Selection.on_change", - DeprecationWarning, - ) - on_change = on_select - ###################################################################### - # End backwards compatibility. - ###################################################################### - self._items: SourceT | ListSource self.on_change = None # needed for _impl initialization @@ -190,24 +172,3 @@ def on_change(self) -> OnChangeHandler: @on_change.setter def on_change(self, handler: toga.widgets.selection.OnChangeHandler) -> None: self._on_change = wrapped_handler(self, handler) - - ###################################################################### - # 2023-05: Backwards compatibility - ###################################################################### - - @property - def on_select(self) -> OnChangeHandler: - """**DEPRECATED**: Use ``on_change``""" - warnings.warn( - "Selection.on_select has been renamed Selection.on_change.", - DeprecationWarning, - ) - return self.on_change - - @on_select.setter - def on_select(self, handler: toga.widgets.selection.OnChangeHandler) -> None: - warnings.warn( - "Selection.on_select has been renamed Selection.on_change.", - DeprecationWarning, - ) - self.on_change = handler diff --git a/core/src/toga/widgets/slider.py b/core/src/toga/widgets/slider.py index dcecb9aa94..f1052a80a1 100644 --- a/core/src/toga/widgets/slider.py +++ b/core/src/toga/widgets/slider.py @@ -1,6 +1,5 @@ from __future__ import annotations -import warnings from abc import ABC, abstractmethod from contextlib import contextmanager from typing import Any, Protocol, SupportsFloat @@ -46,14 +45,13 @@ def __init__( id: str | None = None, style: StyleT | None = None, value: float | None = None, - min: float | None = None, # Default to 0.0 when range is removed - max: float | None = None, # Default to 1.0 when range is removed + min: float = 0.0, + max: float = 1.0, tick_count: int | None = None, on_change: toga.widgets.slider.OnChangeHandler | None = None, on_press: toga.widgets.slider.OnPressHandler | None = None, on_release: OnReleaseHandler | None = None, enabled: bool = True, - range: None = None, # DEPRECATED ): """Create a new Slider widget. @@ -70,36 +68,9 @@ def __init__( :param on_press: Initial :any:`on_press` handler. :param on_release: Initial :any:`on_release` handler. :param enabled: Whether the user can interact with the widget. - :param range: **DEPRECATED**; use ``min`` and ``max`` instead. Initial - :any:`range` of the slider. Defaults to ``(0, 1)``. """ super().__init__(id=id, style=style) - ###################################################################### - # 2023-06: Backwards compatibility - ###################################################################### - if range is not None: - if min is not None or max is not None: - raise ValueError( - "range cannot be specified if min and max are specified" - ) - else: - warnings.warn( - "Slider.range has been deprecated in favor of " - "Slider.min and Slider.max", - DeprecationWarning, - ) - min, max = range - else: - # This provides defaults values for min/max. - if min is None: - min = 0.0 - if max is None: - max = 1.0 - ###################################################################### - # End backwards compatibility - ###################################################################### - # Set a dummy handler before installing the actual on_change, because we do not # want on_change triggered by the initial value being set self.on_change = None @@ -315,38 +286,6 @@ def on_release(self) -> OnReleaseHandler: def on_release(self, handler: OnReleaseHandler) -> None: self._on_release = wrapped_handler(self, handler) - ###################################################################### - # 2023-06: Backwards compatibility - ###################################################################### - @property - def range(self) -> tuple[float, float]: - """**DEPRECATED**; use :any:`min` and :any:`max` instead. - - Range of allowed values, in the form (min, max). - - If the provided min is greater than the max, both values will assume the value - of the max. - - If the current value is less than the provided ``min``, the current value will - be clipped to the minimum value. If the current value is greater than the - provided ``max``, the current value will be clipped to the maximum value. - """ - warnings.warn( - "Slider.range has been deprecated in favor of Slider.min and Slider.max", - DeprecationWarning, - ) - return self.min, self.max - - @range.setter - def range(self, range: tuple[float, float]) -> None: - warnings.warn( - "Slider.range has been deprecated in favor of Slider.min and Slider.max", - DeprecationWarning, - ) - _min, _max = range - self.min = _min - self.max = _max - class SliderImpl(ABC): interface: Any diff --git a/core/src/toga/widgets/table.py b/core/src/toga/widgets/table.py index e538293e22..4c34cb2601 100644 --- a/core/src/toga/widgets/table.py +++ b/core/src/toga/widgets/table.py @@ -1,6 +1,5 @@ from __future__ import annotations -import warnings from collections.abc import Iterable from typing import Any, Literal, Protocol, TypeVar @@ -45,7 +44,6 @@ def __init__( on_select: toga.widgets.table.OnSelectHandler | None = None, on_activate: toga.widgets.table.OnActivateHandler | None = None, missing_value: str = "", - on_double_click: None = None, # DEPRECATED ): """Create a new Table widget. @@ -76,24 +74,7 @@ def __init__( :param missing_value: The string that will be used to populate a cell when the value provided by its accessor is :any:`None`, or the accessor isn't defined. - :param on_double_click: **DEPRECATED**; use :attr:`on_activate`. """ - ###################################################################### - # 2023-06: Backwards compatibility - ###################################################################### - if on_double_click: - if on_activate: - raise ValueError("Cannot specify both on_double_click and on_activate") - else: - warnings.warn( - "Table.on_double_click has been renamed Table.on_activate.", - DeprecationWarning, - ) - on_activate = on_double_click - ###################################################################### - # End backwards compatibility. - ###################################################################### - self._headings: list[str] | None self._accessors: list[str] self._data: SourceT | ListSource @@ -234,10 +215,6 @@ def on_activate(self) -> OnActivateHandler: def on_activate(self, handler: toga.widgets.table.OnActivateHandler) -> None: self._on_activate = wrapped_handler(self, handler) - def add_column(self, heading: str, accessor: str | None = None) -> None: - """**DEPRECATED**: use :meth:`~toga.Table.append_column`""" - self.insert_column(len(self._accessors), heading, accessor=accessor) - def append_column(self, heading: str, accessor: str | None = None) -> None: """Append a column to the end of the table. @@ -325,24 +302,3 @@ def missing_value(self) -> str: attribute. """ return self._missing_value - - ###################################################################### - # 2023-06: Backwards compatibility - ###################################################################### - - @property - def on_double_click(self) -> OnActivateHandler: - """**DEPRECATED**: Use ``on_activate``""" - warnings.warn( - "Table.on_double_click has been renamed Table.on_activate.", - DeprecationWarning, - ) - return self.on_activate - - @on_double_click.setter - def on_double_click(self, handler: toga.widgets.table.OnActivateHandler) -> None: - warnings.warn( - "Table.on_double_click has been renamed Table.on_activate.", - DeprecationWarning, - ) - self.on_activate = handler diff --git a/core/src/toga/widgets/timeinput.py b/core/src/toga/widgets/timeinput.py index 1e0aec970e..1d3e46438a 100644 --- a/core/src/toga/widgets/timeinput.py +++ b/core/src/toga/widgets/timeinput.py @@ -1,7 +1,6 @@ from __future__ import annotations import datetime -import warnings from typing import Any, Protocol import toga @@ -141,54 +140,3 @@ def on_change(self) -> OnChangeHandler: @on_change.setter def on_change(self, handler: toga.widgets.timeinput.OnChangeHandler) -> None: self._on_change = wrapped_handler(self, handler) - - -# 2023-05: Backwards compatibility -class TimePicker(TimeInput): - def __init__(self, *args: Any, **kwargs: Any): - warnings.warn("TimePicker has been renamed TimeInput", DeprecationWarning) - - for old_name, new_name in [ - ("min_time", "min"), - ("max_time", "max"), - ]: - try: - value = kwargs.pop(old_name) - warnings.warn( - f"TimePicker.{old_name} has been renamed TimeInput.{new_name}", - DeprecationWarning, - ) - except KeyError: - pass - else: - kwargs[new_name] = value - - super().__init__(*args, **kwargs) - - @property - def min_time(self) -> datetime.time: - warnings.warn( - "TimePicker.min_time has been renamed TimeInput.min", DeprecationWarning - ) - return self.min - - @min_time.setter - def min_time(self, value: object) -> None: - warnings.warn( - "TimePicker.min_time has been renamed TimeInput.min", DeprecationWarning - ) - self.min = value - - @property - def max_time(self) -> datetime.time: - warnings.warn( - "TimePicker.max_time has been renamed TimeInput.max", DeprecationWarning - ) - return self.max - - @max_time.setter - def max_time(self, value: object) -> None: - warnings.warn( - "TimePicker.max_time has been renamed TimeInput.max", DeprecationWarning - ) - self.max = value diff --git a/core/src/toga/widgets/tree.py b/core/src/toga/widgets/tree.py index 18a6529a13..cb51172ee7 100644 --- a/core/src/toga/widgets/tree.py +++ b/core/src/toga/widgets/tree.py @@ -1,6 +1,5 @@ from __future__ import annotations -import warnings from collections.abc import Iterable from typing import Any, Literal, Protocol, TypeVar @@ -45,7 +44,6 @@ def __init__( on_select: toga.widgets.tree.OnSelectHandler | None = None, on_activate: toga.widgets.tree.OnActivateHandler | None = None, missing_value: str = "", - on_double_click: None = None, # DEPRECATED ): """Create a new Tree widget. @@ -76,24 +74,7 @@ def __init__( :param missing_value: The string that will be used to populate a cell when the value provided by its accessor is :any:`None`, or the accessor isn't defined. - :param on_double_click: **DEPRECATED**; use :attr:`on_activate`. """ - ###################################################################### - # 2023-06: Backwards compatibility - ###################################################################### - if on_double_click: - if on_activate: - raise ValueError("Cannot specify both on_double_click and on_activate") - else: - warnings.warn( - "Tree.on_double_click has been renamed Tree.on_activate.", - DeprecationWarning, - ) - on_activate = on_double_click - ###################################################################### - # End backwards compatibility. - ###################################################################### - self._headings: list[str] | None self._data: SourceT | TreeSource @@ -323,24 +304,3 @@ def on_activate(self) -> OnActivateHandler: @on_activate.setter def on_activate(self, handler: toga.widgets.tree.OnActivateHandler) -> None: self._on_activate = wrapped_handler(self, handler) - - ###################################################################### - # 2023-06: Backwards compatibility - ###################################################################### - - @property - def on_double_click(self) -> OnActivateHandler: - """**DEPRECATED**: Use ``on_activate``""" - warnings.warn( - "Tree.on_double_click has been renamed Tree.on_activate.", - DeprecationWarning, - ) - return self.on_activate - - @on_double_click.setter - def on_double_click(self, handler: toga.widgets.tree.OnActivateHandler) -> None: - warnings.warn( - "Tree.on_double_click has been renamed Tree.on_activate.", - DeprecationWarning, - ) - self.on_activate = handler diff --git a/core/src/toga/window.py b/core/src/toga/window.py index f8788e6570..812ccca58a 100644 --- a/core/src/toga/window.py +++ b/core/src/toga/window.py @@ -142,8 +142,6 @@ def __init__( minimizable: bool = True, on_close: OnCloseHandler | None = None, content: Widget | None = None, - resizeable: None = None, # DEPRECATED - closeable: None = None, # DEPRECATED ) -> None: """Create a new Window. @@ -159,29 +157,7 @@ def __init__( :param minimizable: Can the window be minimized by the user? :param on_close: The initial :any:`on_close` handler. :param content: The initial content for the window. - :param resizeable: **DEPRECATED** - Use ``resizable``. - :param closeable: **DEPRECATED** - Use ``closable``. """ - ###################################################################### - # 2023-08: Backwards compatibility - ###################################################################### - if resizeable is not None: - warnings.warn( - "Window.resizeable has been renamed Window.resizable", - DeprecationWarning, - ) - resizable = resizeable - - if closeable is not None: - warnings.warn( - "Window.closeable has been renamed Window.closable", - DeprecationWarning, - ) - closable = closeable - ###################################################################### - # End backwards compatibility - ###################################################################### - # Needs to be a late import to avoid circular dependencies. from toga import App @@ -555,7 +531,7 @@ def cleanup(window: Window, should_close: bool) -> None: self._on_close = wrapped_handler(self, handler, cleanup=cleanup) ###################################################################### - # 2024-06: Backwards compatibility + # 2024-06: Backwards compatibility for <= 0.4.5 ###################################################################### def info_dialog( @@ -565,16 +541,10 @@ def info_dialog( on_result: DialogResultHandler[None] | None = None, ) -> Dialog: """**DEPRECATED** - await :meth:`dialog` with an :any:`InfoDialog`""" - ###################################################################### - # 2024-06: Backwards compatibility - ###################################################################### warnings.warn( "info_dialog(...) has been deprecated; use dialog(toga.InfoDialog(...))", DeprecationWarning, ) - ###################################################################### - # End Backwards compatibility - ###################################################################### result = Dialog( self, @@ -591,17 +561,11 @@ def question_dialog( on_result: DialogResultHandler[bool] | None = None, ) -> Dialog: """**DEPRECATED** - await :meth:`dialog` with a :any:`QuestionDialog`""" - ###################################################################### - # 2024-06: Backwards compatibility - ###################################################################### warnings.warn( "question_dialog(...) has been deprecated; " "use dialog(toga.QuestionDialog(...))", DeprecationWarning, ) - ###################################################################### - # End Backwards compatibility - ###################################################################### result = Dialog( self, @@ -618,17 +582,11 @@ def confirm_dialog( on_result: DialogResultHandler[bool] | None = None, ) -> Dialog: """**DEPRECATED** - await :meth:`dialog` with a :any:`ConfirmDialog`""" - ###################################################################### - # 2024-06: Backwards compatibility - ###################################################################### warnings.warn( "confirm_dialog(...) has been deprecated; " "use dialog(toga.ConfirmDialog(...))", DeprecationWarning, ) - ###################################################################### - # End Backwards compatibility - ###################################################################### result = Dialog( self, @@ -645,16 +603,10 @@ def error_dialog( on_result: DialogResultHandler[None] | None = None, ) -> Dialog: """**DEPRECATED** - await :meth:`dialog` with an :any:`ErrorDialog`""" - ###################################################################### - # 2024-06: Backwards compatibility - ###################################################################### warnings.warn( "error_dialog(...) has been deprecated; use dialog(toga.ErrorDialog(...))", DeprecationWarning, ) - ###################################################################### - # End Backwards compatibility - ###################################################################### result = Dialog( self, @@ -673,17 +625,11 @@ def stack_trace_dialog( on_result: DialogResultHandler[bool] | DialogResultHandler[None] | None = None, ) -> Dialog: """**DEPRECATED** - await :meth:`dialog` with a :any:`StackTraceDialog`""" - ###################################################################### - # 2024-06: Backwards compatibility - ###################################################################### warnings.warn( "stack_trace_dialog(...) has been deprecated; " "use dialog(toga.StackTraceDialog(...))", DeprecationWarning, ) - ###################################################################### - # End Backwards compatibility - ###################################################################### result = Dialog( self, @@ -706,17 +652,11 @@ def save_file_dialog( on_result: DialogResultHandler[Path | None] | None = None, ) -> Dialog: """**DEPRECATED** - await :meth:`dialog` with a :any:`SaveFileDialog`""" - ###################################################################### - # 2024-06: Backwards compatibility - ###################################################################### warnings.warn( "save_file_dialog(...) has been deprecated; " "use dialog(toga.SaveFileDialog(...))", DeprecationWarning, ) - ###################################################################### - # End Backwards compatibility - ###################################################################### result = Dialog( self, on_result=wrapped_handler(self, on_result) if on_result else None, @@ -741,34 +681,13 @@ def open_file_dialog( | DialogResultHandler[None] | None ) = None, - multiselect: None = None, # DEPRECATED ) -> Dialog: """**DEPRECATED** - await :meth:`dialog` with an :any:`OpenFileDialog`""" - ###################################################################### - # 2024-06: Backwards compatibility - ###################################################################### warnings.warn( "open_file_dialog(...) has been deprecated; " "use dialog(toga.OpenFileDialog(...))", DeprecationWarning, ) - ###################################################################### - # End Backwards compatibility - ###################################################################### - - ###################################################################### - # 2023-08: Backwards compatibility - ###################################################################### - if multiselect is not None: - warnings.warn( - "open_file_dialog(multiselect) has been renamed multiple_select", - DeprecationWarning, - ) - multiple_select = multiselect - ###################################################################### - # End Backwards compatibility - ###################################################################### - result = Dialog( self, on_result=wrapped_handler(self, on_result) if on_result else None, @@ -793,33 +712,13 @@ def select_folder_dialog( | DialogResultHandler[None] | None ) = None, - multiselect: None = None, # DEPRECATED ) -> Dialog: """**DEPRECATED** - await :meth:`dialog` with a :any:`SelectFolderDialog`""" - ###################################################################### - # 2024-06: Backwards compatibility - ###################################################################### warnings.warn( "select_folder_dialog(...) has been deprecated; " "use dialog(toga.SelectFolderDialog(...))", DeprecationWarning, ) - ###################################################################### - # End Backwards compatibility - ###################################################################### - - ###################################################################### - # 2023-08: Backwards compatibility - ###################################################################### - if multiselect is not None: - warnings.warn( - "select_folder_dialog(multiselect) has been renamed multiple_select", - DeprecationWarning, - ) - multiple_select = multiselect - ###################################################################### - # End Backwards compatibility - ###################################################################### result = Dialog( self, on_result=wrapped_handler(self, on_result) if on_result else None, @@ -833,32 +732,11 @@ def select_folder_dialog( return result ###################################################################### - # 2023-08: Backwards compatibility - ###################################################################### - @property - def resizeable(self) -> bool: - """**DEPRECATED** Use :attr:`resizable`""" - warnings.warn( - "Window.resizeable has been renamed Window.resizable", - DeprecationWarning, - ) - return self._resizable - - @property - def closeable(self) -> bool: - """**DEPRECATED** Use :attr:`closable`""" - warnings.warn( - "Window.closeable has been renamed Window.closable", - DeprecationWarning, - ) - return self._closable - - ###################################################################### - # End Backwards compatibility + # End backwards compatibility ###################################################################### ###################################################################### - # 2024-10: Backwards compatibility + # 2024-10: Backwards compatibility for <= 0.4.8 ###################################################################### @property def full_screen(self) -> bool: @@ -942,33 +820,6 @@ def discard(self, window: Window) -> None: raise ValueError(f"{window!r} is not part of this app") self.elements.remove(window) - ###################################################################### - # 2023-10: Backwards compatibility - ###################################################################### - - def __iadd__(self, window: Window) -> WindowSet: - # The standard set type does not have a += operator. - warnings.warn( - "Windows are automatically associated with the app; += is not required", - DeprecationWarning, - stacklevel=2, - ) - return self - - def __isub__(self, other: Window) -> WindowSet: - # The standard set type does have a -= operator, but it takes sets rather than - # individual items. - warnings.warn( - "Windows are automatically removed from the app; -= is not required", - DeprecationWarning, - stacklevel=2, - ) - return self - - ###################################################################### - # End backwards compatibility - ###################################################################### - def __iter__(self) -> Iterator[Window]: return iter(self.elements) diff --git a/core/tests/app/test_app.py b/core/tests/app/test_app.py index a24f7c571e..52caea67b9 100644 --- a/core/tests/app/test_app.py +++ b/core/tests/app/test_app.py @@ -260,11 +260,6 @@ def test_create( RuntimeError, "Toga application must have an app ID", ), - ( - dict(windows=()), - ValueError, - "The `windows` constructor argument of toga.App has been removed", - ), ], ) def test_bad_app_creation(kwargs, exc_type, message): @@ -952,28 +947,6 @@ def test_dark_mode_state(app): assert app.dark_mode -def test_deprecated_id(event_loop): - """The deprecated `id` constructor argument is ignored, and the property of the same - name is redirected to `app_id`""" - id_warning = r"App.id is deprecated.* Use app_id instead" - with pytest.warns(DeprecationWarning, match=id_warning): - app = toga.App("Test App", "org.example.test", id="test_app_id") - - assert app.app_id == "org.example.test" - with pytest.warns(DeprecationWarning, match=id_warning): - assert app.id == "org.example.test" - - -def test_deprecated_name(event_loop): - """The deprecated `name` property is redirected to `formal_name`""" - name_warning = r"App.name is deprecated. Use formal_name instead" - app = toga.App("Test App", "org.example.test") - - assert app.formal_name == "Test App" - with pytest.warns(DeprecationWarning, match=name_warning): - assert app.name == "Test App" - - def test_deprecated_background_task(app): """A background task can be queued using the deprecated API.""" canary = Mock() diff --git a/core/tests/app/test_windowset.py b/core/tests/app/test_windowset.py index 0f7d69add0..cac95cb980 100644 --- a/core/tests/app/test_windowset.py +++ b/core/tests/app/test_windowset.py @@ -58,32 +58,3 @@ def test_add_discard(app, window1, window2): match=r"Can only discard objects of type toga.Window", ): app.windows.discard(object()) - - -def test_iadd_isub(app, window1, window2): - """The deprecated += and -= operators are no-ops.""" - # The windowset has 3 windows - the main window, plus 2 extras - assert window2 in app.windows - assert len(app.windows) == 3 - - with pytest.warns( - DeprecationWarning, - match=r"Windows are automatically associated with the app; \+= is not required", - ): - app.windows += window2 - - assert window2 in app.windows - assert len(app.windows) == 3 - - with pytest.warns( - DeprecationWarning, - match=r"Windows are automatically removed from the app; -= is not required", - ): - app.windows -= window2 - - # -= is a no-op. - assert window2 in app.windows - assert len(app.windows) == 3 - - with pytest.raises(AttributeError, match=r"can't set attribute 'windows'"): - app.windows = None diff --git a/core/tests/test_handlers.py b/core/tests/test_handlers.py index aad58f6d00..090ef4dde6 100644 --- a/core/tests/test_handlers.py +++ b/core/tests/test_handlers.py @@ -624,7 +624,7 @@ async def handler(*args, **kwargs): ###################################################################### -# 2023-12: Backwards compatibility +# 2023-12: Backwards compatibility for <= 0.4.0 ###################################################################### diff --git a/core/tests/test_icons.py b/core/tests/test_icons.py index 01fb6c561f..4b07bb5328 100644 --- a/core/tests/test_icons.py +++ b/core/tests/test_icons.py @@ -255,13 +255,3 @@ def test_cached_icons(app, name, path): # Retrieve the icon a second time; The same instance is returned. assert id(getattr(toga.Icon, name)) == id(icon) - - -def test_deprecated_icons(app): - """Deprecated icons are still available.""" - with pytest.warns(DeprecationWarning): - icon = toga.Icon.TOGA_ICON - assert icon.path == Path("toga") - - # Retrieve the icon a second time; The same instance is returned. - assert id(toga.Icon.TOGA_ICON) == id(icon) diff --git a/core/tests/widgets/canvas/test_canvas.py b/core/tests/widgets/canvas/test_canvas.py index c1e4d4a553..1d2378ee17 100644 --- a/core/tests/widgets/canvas/test_canvas.py +++ b/core/tests/widgets/canvas/test_canvas.py @@ -2,7 +2,7 @@ import toga from toga.colors import rgb -from toga.constants import Baseline, FillRule +from toga.constants import FillRule from toga.fonts import SYSTEM, SYSTEM_DEFAULT_FONT_SIZE, Font from toga.widgets.canvas import ClosedPathContext, Context, FillContext, StrokeContext from toga_dummy.utils import assert_action_not_performed, assert_action_performed @@ -158,272 +158,3 @@ def test_as_image(widget): image = widget.as_image() assert image is not None assert_action_performed(widget, "get image data") - - -def test_deprecated_drawing_operations(widget): - """Deprecated simple drawing operations raise a warning.""" - - with pytest.warns( - DeprecationWarning, - match=( - r"Direct canvas operations have been deprecated; " - r"use context.begin_path()" - ), - ): - widget.new_path() - - with pytest.warns( - DeprecationWarning, - match=r"Direct canvas operations have been deprecated; use context.move_to()", - ): - widget.move_to(10, 20) - - with pytest.warns( - DeprecationWarning, - match=r"Direct canvas operations have been deprecated; use context.line_to()", - ): - widget.line_to(10, 20) - - with pytest.warns( - DeprecationWarning, - match=( - r"Direct canvas operations have been deprecated; " - r"use context.bezier_curve_to()" - ), - ): - widget.bezier_curve_to(1, 2, 3, 4, 10, 20) - - with pytest.warns( - DeprecationWarning, - match=( - r"Direct canvas operations have been deprecated; " - r"use context.quadratic_curve_to()" - ), - ): - widget.quadratic_curve_to(1, 2, 10, 20) - - with pytest.warns( - DeprecationWarning, - match=r"Direct canvas operations have been deprecated; use context.arc()", - ): - widget.arc(10, 20, 30, 0.4, 0.5, True) - - with pytest.warns( - DeprecationWarning, - match=r"Direct canvas operations have been deprecated; use context.ellipse()", - ): - widget.ellipse(10, 20, 30, 40, 0.4, 0.5, 0.6, True) - - with pytest.warns( - DeprecationWarning, - match=r"Direct canvas operations have been deprecated; use context.rect()", - ): - widget.rect(10, 20, 30, 40) - - with pytest.warns( - DeprecationWarning, - match=( - r"Direct canvas operations have been deprecated; " - r"use context.write_text()" - ), - ): - widget.write_text("Hello World", 10, 20, Font("Cutive", 37)) - - with pytest.warns( - DeprecationWarning, - match=r"Direct canvas operations have been deprecated; use context.rotate()", - ): - widget.rotate(0.4) - - with pytest.warns( - DeprecationWarning, - match=r"Direct canvas operations have been deprecated; use context.scale()", - ): - widget.scale(0.4, 0.5) - - with pytest.warns( - DeprecationWarning, - match=r"Direct canvas operations have been deprecated; use context.translate()", - ): - widget.translate(10, 20) - - with pytest.warns( - DeprecationWarning, - match=( - r"Direct canvas operations have been deprecated; " - r"use context.reset_transform()" - ), - ): - widget.reset_transform() - - with pytest.warns( - DeprecationWarning, - match=r"Canvas.closed_path\(\) has been renamed Canvas.ClosedPath\(\)", - ): - with widget.closed_path(10, 20) as closed_path: - closed_path.line_to(20, 30) - closed_path.line_to(30, 20) - - with pytest.warns( - DeprecationWarning, - match=r"Canvas.fill\(\) has been renamed Canvas.Fill\(\)", - ): - with widget.fill("rebeccapurple", FillRule.EVENODD) as fill: - fill.line_to(20, 30) - fill.line_to(30, 20) - - with pytest.warns( - DeprecationWarning, - match=r"Canvas.stroke\(\) has been renamed Canvas.Stroke\(\)", - ): - with widget.stroke("rebeccapurple", 3.0, [2, 7]) as stroke: - stroke.line_to(20, 30) - stroke.line_to(30, 20) - - # Assert the deprecated draw instructions rendered as expected - assert widget._impl.draw_instructions == [ - ("push context", {}), - ("begin path", {}), - ("move to", {"x": 10, "y": 20}), - ("line to", {"x": 10, "y": 20}), - ( - "bezier curve to", - {"cp1x": 1, "cp1y": 2, "cp2x": 3, "cp2y": 4, "x": 10, "y": 20}, - ), - ( - "quadratic curve to", - {"cpx": 1, "cpy": 2, "x": 10, "y": 20}, - ), - ( - "arc", - { - "x": 10, - "y": 20, - "radius": 30, - "startangle": 0.4, - "endangle": 0.5, - "anticlockwise": True, - }, - ), - ( - "ellipse", - { - "x": 10, - "y": 20, - "radiusx": 30, - "radiusy": 40, - "rotation": 0.4, - "startangle": 0.5, - "endangle": 0.6, - "anticlockwise": True, - }, - ), - ("rect", {"x": 10, "y": 20, "width": 30, "height": 40}), - ( - "write text", - { - "text": "Hello World", - "x": 10, - "y": 20, - "font": Font("Cutive", 37)._impl, - "baseline": Baseline.ALPHABETIC, - }, - ), - ("rotate", {"radians": 0.4}), - ("scale", {"sx": 0.4, "sy": 0.5}), - ("translate", {"tx": 10, "ty": 20}), - ("reset transform", {}), - # ClosedPath - ("push context", {}), - ("begin path", {}), - ("move to", {"x": 10, "y": 20}), - ("line to", {"x": 20, "y": 30}), - ("line to", {"x": 30, "y": 20}), - ("close path", {}), - ("pop context", {}), - # Fill - ("push context", {}), - ("begin path", {}), - ( - "line to", - { - "x": 20, - "y": 30, - "fill_color": REBECCA_PURPLE_COLOR, - "fill_rule": FillRule.EVENODD, - }, - ), - ( - "line to", - { - "x": 30, - "y": 20, - "fill_color": REBECCA_PURPLE_COLOR, - "fill_rule": FillRule.EVENODD, - }, - ), - ("fill", {"color": REBECCA_PURPLE_COLOR, "fill_rule": FillRule.EVENODD}), - ("pop context", {}), - # Stroke - ("push context", {}), - ("begin path", {}), - ( - "line to", - { - "x": 20, - "y": 30, - "stroke_color": REBECCA_PURPLE_COLOR, - "line_width": 3.0, - "line_dash": [2, 7], - }, - ), - ( - "line to", - { - "x": 30, - "y": 20, - "stroke_color": REBECCA_PURPLE_COLOR, - "line_width": 3.0, - "line_dash": [2, 7], - }, - ), - ( - "stroke", - {"color": REBECCA_PURPLE_COLOR, "line_width": 3.0, "line_dash": [2, 7]}, - ), - ("pop context", {}), - ("pop context", {}), - ] - - -def test_deprecated_args(widget): - """Deprecated arguments to canvas functions raise warnings.""" - with pytest.warns( - DeprecationWarning, - match=r"The `tight` argument on Canvas.measure_text\(\) has been deprecated.", - ): - assert widget.measure_text( - "Hello world", font=Font(family="Cutive", size=42), tight=True - ) == (693, 63) - - with pytest.warns( - DeprecationWarning, - match=r"Canvas.fill\(\) has been renamed Canvas.Fill\(\)", - ), pytest.warns( - DeprecationWarning, - match=r"The `preserve` argument on fill\(\) has been deprecated.", - ): - with widget.fill("rebeccapurple", FillRule.EVENODD, preserve=False) as fill: - fill.line_to(20, 30) - fill.line_to(30, 20) - - widget._impl.draw_instructions == [ - ("push context", {}), - ("push context", {}), - ("begin path", {}), - ("line to", {"x": 20, "y": 30}), - ("line to", {"x": 30, "y": 20}), - ("fill", {"color": REBECCA_PURPLE_COLOR, "fill_rule": FillRule.EVENODD}), - ("pop context", {}), - ("pop context", {}), - ] diff --git a/core/tests/widgets/canvas/test_context_objects.py b/core/tests/widgets/canvas/test_context_objects.py index 79171565b6..655d7ce735 100644 --- a/core/tests/widgets/canvas/test_context_objects.py +++ b/core/tests/widgets/canvas/test_context_objects.py @@ -385,52 +385,6 @@ def test_stroke(widget, kwargs, args_repr, has_move, properties): ] -def test_deprecated_drawing_operations(widget): - """Deprecated simple drawing operations raise a warning.""" - - with pytest.warns( - DeprecationWarning, - match=r"Context.new_path\(\) has been renamed Context.begin_path\(\)", - ): - widget.context.new_path() - - with pytest.warns( - DeprecationWarning, - match=r"Context.context\(\) has been renamed Context.Context\(\)", - ): - with widget.context.context() as subcontext: - subcontext.line_to(20, 30) - subcontext.line_to(30, 20) - - with pytest.warns( - DeprecationWarning, - match=r"Context.closed_path\(\) has been renamed Context.ClosedPath\(\)", - ): - with widget.context.closed_path(10, 20) as closed_path: - closed_path.line_to(20, 30) - closed_path.line_to(30, 20) - - # Assert the deprecated draw instructions rendered as expected - assert widget._impl.draw_instructions == [ - ("push context", {}), - ("begin path", {}), - # Context - ("push context", {}), - ("line to", {"x": 20, "y": 30}), - ("line to", {"x": 30, "y": 20}), - ("pop context", {}), - # ClosedPath - ("push context", {}), - ("begin path", {}), - ("move to", {"x": 10, "y": 20}), - ("line to", {"x": 20, "y": 30}), - ("line to", {"x": 30, "y": 20}), - ("close path", {}), - ("pop context", {}), - ("pop context", {}), - ] - - def test_order_change(widget): """The order of context objects can be changed.""" # Initially nothing on the context. @@ -837,23 +791,3 @@ def test_stacked_kwargs(widget): ("line to", {"x": 99, "y": 99}), ("pop context", {}), ] - - -def test_deprecated_args(widget): - """Deprecated arguments to canvas functions raise warnings.""" - - # fill() raises a warning about preserve being deprecated, then raises an error when - # it's used as a context manager. - with pytest.raises( - RuntimeError, - match=r"Context\.fill\(\) has been renamed Context\.Fill\(\)\.", - ): - with pytest.warns( - DeprecationWarning, - match=r"The `preserve` argument on fill\(\) has been deprecated.", - ): - with widget.context.fill( - "rebeccapurple", FillRule.EVENODD, preserve=False - ) as fill: - fill.line_to(20, 30) - fill.line_to(30, 20) diff --git a/core/tests/widgets/canvas/test_draw_operations.py b/core/tests/widgets/canvas/test_draw_operations.py index 6f1eff52ef..31a788bb86 100644 --- a/core/tests/widgets/canvas/test_draw_operations.py +++ b/core/tests/widgets/canvas/test_draw_operations.py @@ -697,20 +697,3 @@ def test_reset_transform(widget): assert widget._impl.draw_instructions[1:-1] == [ ("reset transform", {}), ] - - -def test_deprecated_usage(widget): - """Test that deprecated usage of operations raise errors.""" - with pytest.raises( - RuntimeError, - match=r"Context\.fill\(\) has been renamed Context\.Fill\(\)\.", - ): - with widget.context.fill() as fill: - fill.line_to(10, 20) - - with pytest.raises( - RuntimeError, - match=r"Context\.stroke\(\) has been renamed Context\.Stroke\(\)\.", - ): - with widget.context.stroke() as stroke: - stroke.line_to(10, 20) diff --git a/core/tests/widgets/test_dateinput.py b/core/tests/widgets/test_dateinput.py index d6c4f79737..cf32a467f2 100644 --- a/core/tests/widgets/test_dateinput.py +++ b/core/tests/widgets/test_dateinput.py @@ -242,50 +242,3 @@ def test_max_clip(widget, on_change_handler, max, clip_value, clip_min): assert widget.min == max else: assert widget.min == date(2005, 6, 25) - - -def test_deprecated_names(): - MIN = date(2012, 8, 3) - MAX = date(2016, 11, 15) - - with pytest.warns( - DeprecationWarning, match="DatePicker has been renamed DateInput" - ), pytest.warns( - DeprecationWarning, match="DatePicker.min_date has been renamed DateInput.min" - ), pytest.warns( - DeprecationWarning, match="DatePicker.max_date has been renamed DateInput.max" - ): - widget = toga.DatePicker(min_date=MIN, max_date=MAX) - - assert widget.min == MIN - assert widget.max == MAX - widget.min = widget.max = None - - with pytest.warns( - DeprecationWarning, match="DatePicker.min_date has been renamed DateInput.min" - ): - widget.min_date = MIN - - with pytest.warns( - DeprecationWarning, match="DatePicker.min_date has been renamed DateInput.min" - ): - assert widget.min_date == MIN - assert widget.min == MIN - - with pytest.warns( - DeprecationWarning, match="DatePicker.max_date has been renamed DateInput.max" - ): - widget.max_date = MAX - - with pytest.warns( - DeprecationWarning, match="DatePicker.max_date has been renamed DateInput.max" - ): - assert widget.max_date == MAX - assert widget.max == MAX - - with pytest.warns( - DeprecationWarning, match="DatePicker has been renamed DateInput" - ): - widget = toga.DatePicker() - assert widget.min == date(1800, 1, 1) - assert widget.max == date(8999, 12, 31) diff --git a/core/tests/widgets/test_detailedlist.py b/core/tests/widgets/test_detailedlist.py index c22fc7d4dc..addf5bf79e 100644 --- a/core/tests/widgets/test_detailedlist.py +++ b/core/tests/widgets/test_detailedlist.py @@ -306,43 +306,3 @@ def test_scroll_to_bottom(detailedlist): detailedlist.scroll_to_bottom() assert_action_performed_with(detailedlist, "scroll to row", row=2) - - -###################################################################### -# 2023-07: Backwards compatibility -###################################################################### -def test_deprecated_names(on_primary_action_handler): - """Deprecated names still work.""" - - # Can't specify both on_delete and on_primary_action - with pytest.raises( - ValueError, - match=r"Cannot specify both on_delete and on_primary_action", - ): - toga.DetailedList(on_delete=Mock(), on_primary_action=Mock()) - - # on_delete is redirected at construction - with pytest.warns( - DeprecationWarning, - match="DetailedList.on_delete has been renamed DetailedList.on_primary_action", - ): - select = toga.DetailedList(on_delete=on_primary_action_handler) - - # on_delete accessor is redirected to on_primary_action - with pytest.warns( - DeprecationWarning, - match="DetailedList.on_delete has been renamed DetailedList.on_primary_action", - ): - assert select.on_delete._raw == on_primary_action_handler - - assert select.on_primary_action._raw == on_primary_action_handler - - # on_delete mutator is redirected to on_primary_action - new_handler = Mock() - with pytest.warns( - DeprecationWarning, - match="DetailedList.on_delete has been renamed DetailedList.on_primary_action", - ): - select.on_delete = new_handler - - assert select.on_primary_action._raw == new_handler diff --git a/core/tests/widgets/test_numberinput.py b/core/tests/widgets/test_numberinput.py index ffb2d0d61f..9dfcd16ee1 100644 --- a/core/tests/widgets/test_numberinput.py +++ b/core/tests/widgets/test_numberinput.py @@ -495,66 +495,3 @@ def test_clean_decimal_str(value, clean): ) def test_clean_decimal(value, step, clean): assert _clean_decimal(value, Decimal(step) if step else step) == Decimal(clean) - - -def test_deprecated_names(): - """The deprecated min_value/max_value names still work.""" - # Can't specify min and min_value - with pytest.raises( - ValueError, - match=r"Cannot specify both min and min_value", - ): - toga.NumberInput(min=2, min_value=4) - - # Can't specify min and min_value - with pytest.raises( - ValueError, - match=r"Cannot specify both max and max_value", - ): - toga.NumberInput(max=2, max_value=4) - - # min_value is deprecated - with pytest.warns( - DeprecationWarning, - match="NumberInput.min_value has been renamed NumberInput.min", - ): - widget = toga.NumberInput(min_value=2) - - assert widget.min == 2 - - with pytest.warns( - DeprecationWarning, - match="NumberInput.min_value has been renamed NumberInput.min", - ): - assert widget.min_value == 2 - - with pytest.warns( - DeprecationWarning, - match="NumberInput.min_value has been renamed NumberInput.min", - ): - widget.min_value = 4 - - assert widget.min == 4 - - # max_value is deprecated - with pytest.warns( - DeprecationWarning, - match="NumberInput.max_value has been renamed NumberInput.max", - ): - widget = toga.NumberInput(max_value=2) - - assert widget.max == 2 - - with pytest.warns( - DeprecationWarning, - match="NumberInput.max_value has been renamed NumberInput.max", - ): - assert widget.max_value == 2 - - with pytest.warns( - DeprecationWarning, - match="NumberInput.max_value has been renamed NumberInput.max", - ): - widget.max_value = 4 - - assert widget.max == 4 diff --git a/core/tests/widgets/test_selection.py b/core/tests/widgets/test_selection.py index edbb067030..24aaefa70b 100644 --- a/core/tests/widgets/test_selection.py +++ b/core/tests/widgets/test_selection.py @@ -364,45 +364,3 @@ def test_change_source(widget, on_change_handler): # The widget must have cleared its selection on_change_handler.assert_called_once_with(widget) assert widget.value.key == "new 1" - - -###################################################################### -# 2023-05: Backwards compatibility -###################################################################### - - -def test_deprecated_names(on_change_handler): - """Deprecated names still work.""" - - # Can't specify both on_select and on_change - with pytest.raises( - ValueError, - match=r"Cannot specify both on_select and on_change", - ): - toga.Selection(on_select=Mock(), on_change=Mock()) - - # on_select is redirected at construction - with pytest.warns( - DeprecationWarning, - match="Selection.on_select has been renamed Selection.on_change", - ): - select = toga.Selection(on_select=on_change_handler) - - # on_select accessor is redirected to on_change - with pytest.warns( - DeprecationWarning, - match="Selection.on_select has been renamed Selection.on_change", - ): - assert select.on_select._raw == on_change_handler - - assert select.on_change._raw == on_change_handler - - # on_select mutator is redirected to on_change - new_handler = Mock() - with pytest.warns( - DeprecationWarning, - match="Selection.on_select has been renamed Selection.on_change", - ): - select.on_select = new_handler - - assert select.on_change._raw == new_handler diff --git a/core/tests/widgets/test_slider.py b/core/tests/widgets/test_slider.py index 143e6502c4..43f82a8e55 100644 --- a/core/tests/widgets/test_slider.py +++ b/core/tests/widgets/test_slider.py @@ -544,54 +544,3 @@ def test_int_impl_on_change(tick_count, data): impl.on_change() assert impl.get_value() == approx(value) impl.interface.on_change.assert_called_once_with() - - -def test_deprecated(): - """Check the deprecated min/max naming.""" - # Can't specify min and range - with pytest.raises( - ValueError, - match=r"range cannot be specified if min and max are specified", - ): - toga.Slider(min=2, range=(2, 4)) - - # Can't specify max and range - with pytest.raises( - ValueError, - match=r"range cannot be specified if min and max are specified", - ): - toga.Slider(max=4, range=(2, 4)) - - # Can't specify min and max and range - with pytest.raises( - ValueError, - match=r"range cannot be specified if min and max are specified", - ): - toga.Slider(min=2, max=4, range=(2, 4)) - - # Range is deprecated - with pytest.warns( - DeprecationWarning, - match="Slider.range has been deprecated in favor of Slider.min and Slider.max", - ): - widget = toga.Slider(range=(2, 4)) - - # range is converted to min/max - assert widget.min == pytest.approx(2) - assert widget.max == pytest.approx(4) - - with pytest.warns( - DeprecationWarning, - match="Slider.range has been deprecated in favor of Slider.min and Slider.max", - ): - assert widget.range == (pytest.approx(2), pytest.approx(4)) - - # range is converted to min/max - with pytest.warns( - DeprecationWarning, - match="Slider.range has been deprecated in favor of Slider.min and Slider.max", - ): - widget.range = (6, 8) - - assert widget.min == pytest.approx(6) - assert widget.max == pytest.approx(8) diff --git a/core/tests/widgets/test_table.py b/core/tests/widgets/test_table.py index 2da512e0fa..3e80251d3f 100644 --- a/core/tests/widgets/test_table.py +++ b/core/tests/widgets/test_table.py @@ -537,53 +537,3 @@ def test_remove_column_no_headings(table): ) assert table.headings is None assert table.accessors == ["primus"] - - -def test_deprecated_names(on_activate_handler): - """Deprecated names still work.""" - - # Can't specify both on_double_click and on_activate - with pytest.raises( - ValueError, - match=r"Cannot specify both on_double_click and on_activate", - ): - toga.Table(["First", "Second"], on_double_click=Mock(), on_activate=Mock()) - - # on_double_click is redirected at construction - with pytest.warns( - DeprecationWarning, - match="Table.on_double_click has been renamed Table.on_activate", - ): - table = toga.Table(["First", "Second"], on_double_click=on_activate_handler) - - # on_double_click accessor is redirected to on_activate - with pytest.warns( - DeprecationWarning, - match="Table.on_double_click has been renamed Table.on_activate", - ): - assert table.on_double_click._raw == on_activate_handler - - assert table.on_activate._raw == on_activate_handler - - # on_double_click mutator is redirected to on_activate - new_handler = Mock() - with pytest.warns( - DeprecationWarning, - match="Table.on_double_click has been renamed Table.on_activate", - ): - table.on_double_click = new_handler - - assert table.on_activate._raw == new_handler - - # add_column redirects to insert - table.add_column("New Column", "new_accessor") - - assert_action_performed_with( - table, - "insert column", - index=2, - heading="New Column", - accessor="new_accessor", - ) - assert table.headings == ["First", "Second", "New Column"] - assert table.accessors == ["first", "second", "new_accessor"] diff --git a/core/tests/widgets/test_timeinput.py b/core/tests/widgets/test_timeinput.py index 934820ac2c..333acc2d27 100644 --- a/core/tests/widgets/test_timeinput.py +++ b/core/tests/widgets/test_timeinput.py @@ -230,50 +230,3 @@ def test_max_clip(widget, on_change_handler, max, clip_value, clip_min): assert widget.min == max else: assert widget.min == time(3, 42, 37) - - -def test_deprecated_names(): - MIN = time(8, 30, 59) - MAX = time(10, 0, 0) - - with pytest.warns( - DeprecationWarning, match="TimePicker has been renamed TimeInput" - ), pytest.warns( - DeprecationWarning, match="TimePicker.min_time has been renamed TimeInput.min" - ), pytest.warns( - DeprecationWarning, match="TimePicker.max_time has been renamed TimeInput.max" - ): - widget = toga.TimePicker(min_time=MIN, max_time=MAX) - - assert widget.min == MIN - assert widget.max == MAX - widget.min = widget.max = None - - with pytest.warns( - DeprecationWarning, match="TimePicker.min_time has been renamed TimeInput.min" - ): - widget.min_time = MIN - - with pytest.warns( - DeprecationWarning, match="TimePicker.min_time has been renamed TimeInput.min" - ): - assert widget.min_time == MIN - assert widget.min == MIN - - with pytest.warns( - DeprecationWarning, match="TimePicker.max_time has been renamed TimeInput.max" - ): - widget.max_time = MAX - - with pytest.warns( - DeprecationWarning, match="TimePicker.max_time has been renamed TimeInput.max" - ): - assert widget.max_time == MAX - assert widget.max == MAX - - with pytest.warns( - DeprecationWarning, match="TimePicker has been renamed TimeInput" - ): - widget = toga.TimePicker() - assert widget.min == time(0, 0, 0) - assert widget.max == time(23, 59, 59) diff --git a/core/tests/widgets/test_tree.py b/core/tests/widgets/test_tree.py index b5d01d9bef..4ac77e0f1a 100644 --- a/core/tests/widgets/test_tree.py +++ b/core/tests/widgets/test_tree.py @@ -567,40 +567,3 @@ def test_remove_column_no_headings(tree): ) assert tree.headings is None assert tree.accessors == ["primus"] - - -def test_deprecated_names(on_activate_handler): - """Deprecated names still work.""" - - # Can't specify both on_double_click and on_activate - with pytest.raises( - ValueError, - match=r"Cannot specify both on_double_click and on_activate", - ): - toga.Tree(["First", "Second"], on_double_click=Mock(), on_activate=Mock()) - - # on_double_click is redirected at construction - with pytest.warns( - DeprecationWarning, - match="Tree.on_double_click has been renamed Tree.on_activate", - ): - tree = toga.Tree(["First", "Second"], on_double_click=on_activate_handler) - - # on_double_click accessor is redirected to on_activate - with pytest.warns( - DeprecationWarning, - match="Tree.on_double_click has been renamed Tree.on_activate", - ): - assert tree.on_double_click._raw == on_activate_handler - - assert tree.on_activate._raw == on_activate_handler - - # on_double_click mutator is redirected to on_activate - new_handler = Mock() - with pytest.warns( - DeprecationWarning, - match="Tree.on_double_click has been renamed Tree.on_activate", - ): - tree.on_double_click = new_handler - - assert tree.on_activate._raw == new_handler diff --git a/core/tests/window/test_window.py b/core/tests/window/test_window.py index b60e60cd0f..053c3eecce 100644 --- a/core/tests/window/test_window.py +++ b/core/tests/window/test_window.py @@ -1254,9 +1254,6 @@ def test_deprecated_names_open_file_dialog(window, app): window._impl.dialog_responses["OpenFileDialog"] = [opened_files] with pytest.warns( - DeprecationWarning, - match=r"open_file_dialog\(multiselect\) has been renamed multiple_select", - ), pytest.warns( DeprecationWarning, match=( r"Synchronous `on_result` handlers have been deprecated; " @@ -1272,7 +1269,7 @@ def test_deprecated_names_open_file_dialog(window, app): dialog = window.open_file_dialog( "Title", "/path/to/folder", - multiselect=True, + multiple_select=True, on_result=on_result_handler, ) @@ -1302,11 +1299,6 @@ def test_deprecated_names_select_folder_dialog(window, app): window._impl.dialog_responses["SelectFolderDialog"] = [selected_folder] with pytest.warns( - DeprecationWarning, - match=( - r"select_folder_dialog\(multiselect\) " r"has been renamed multiple_select" - ), - ), pytest.warns( DeprecationWarning, match=( r"Synchronous `on_result` handlers have been deprecated; " @@ -1322,7 +1314,7 @@ def test_deprecated_names_select_folder_dialog(window, app): dialog = window.select_folder_dialog( "Title", "/path/to/folder", - multiselect=True, + multiple_select=True, on_result=on_result_handler, ) @@ -1342,36 +1334,6 @@ def test_deprecated_names_select_folder_dialog(window, app): on_result_handler.assert_called_once_with(window, selected_folder) -def test_deprecated_names_resizeable(): - """Deprecated spelling of resizable still works.""" - with pytest.warns( - DeprecationWarning, - match=r"Window.resizeable has been renamed Window.resizable", - ): - window = toga.Window(title="Deprecated", resizeable=True) - - with pytest.warns( - DeprecationWarning, - match=r"Window.resizeable has been renamed Window.resizable", - ): - assert window.resizeable - - -def test_deprecated_names_closeable(): - """Deprecated spelling of closable still works.""" - with pytest.warns( - DeprecationWarning, - match=r"Window.closeable has been renamed Window.closable", - ): - window = toga.Window(title="Deprecated", closeable=True) - - with pytest.warns( - DeprecationWarning, - match=r"Window.closeable has been renamed Window.closable", - ): - assert window.closeable - - def test_deprecated_full_screen(window, app): """A window can be set full screen using the deprecated API.""" full_screen_warning = (