Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message when a platform doesn't support a widget. #1992

Merged
merged 1 commit into from
Jun 19, 2023

Conversation

freakboy3742
Copy link
Member

When a platform doesn't support a widget, the user currently gets an error of the form:

Traceback (most recent call last):
...
  File ".../toga/widgets/datepicker.py", line 43, in __init__
    self._impl = self.factory.DatePicker(interface=self)
AttributeError: module 'toga_gtk.factory' has no attribute 'DatePicker'

This has been the source of regular confusion in support channels, as this isn't a clear indication that a widget isn't supported.

This PR adds a PEP562 handler for the platform factories so that a missing widget in a factory is now reported as:

Traceback (most recent call last):
...
  File ".../toga_gtk/factory.py", line 83, in __getattr__
    raise NotImplementedError(f"Toga's GTK backend doesn't implement {name}")
NotImplementedError: Toga's GTK backend doesn't implement DatePicker

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

@mhsmith mhsmith merged commit 657e551 into beeware:main Jun 19, 2023
@freakboy3742 freakboy3742 deleted the notimpl-helper branch June 26, 2023 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants