Skip to content

Commit

Permalink
Removed 0.4.0 deprecations, for 0.5.0 (#3059)
Browse files Browse the repository at this point in the history
Removed the methods and arguments that were marked as deprecated in the 0.4.0 release.
  • Loading branch information
HalfWhitt authored Dec 23, 2024
1 parent 832bba6 commit b25b4e3
Show file tree
Hide file tree
Showing 38 changed files with 40 additions and 1,723 deletions.
8 changes: 8 additions & 0 deletions android/src/toga_android/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions changes/3059.removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deprecations from 0.4.0 and earlier have been removed.
2 changes: 0 additions & 2 deletions cocoa/src/toga_cocoa/libs/appkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

######################################################################
Expand Down
59 changes: 3 additions & 56 deletions core/src/toga/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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)."""
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -1022,7 +969,7 @@ def set_full_screen(self, *windows: Window) -> None:


######################################################################
# 2024-08: Backwards compatibility
# 2024-08: Backwards compatibility for <= 0.4.5
######################################################################


Expand Down
2 changes: 1 addition & 1 deletion core/src/toga/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 0 additions & 11 deletions core/src/toga/icons.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion core/src/toga/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions core/src/toga/style/applicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions core/src/toga/style/pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions core/src/toga/widgets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit b25b4e3

Please sign in to comment.