ZeroPhone / ZPUI

Official ZeroPhone UI framework, based on pyLCI
http://zpui.rtfd.org/
Apache License 2.0
79 stars 19 forks source link

Replace kwargs.pop(argument) calls with kwargs.pop(argument, default) in UI element constructors #62

Closed CRImier closed 6 years ago

CRImier commented 6 years ago

Some objects in ZPUI, such as UI elements, inherit from other elements, and sometimes __init__ keyword arguments have to be passed through. However, not all of the keyword arguments can be used by the parent elements, so we have to filter through **kwargs to avoid TypeErrors. Here's how the filtering is typically done, as of now:

self.catch_exit = kwargs.pop("catch_exit") if "catch_exit" in kwargs else True

However, it seems this construct can actually be shortened to:

self.catch_exit = kwargs.pop("catch_exit", True)

Tasks:

  1. Find all occurences of the first pattern and shorten them as shown
  2. Test that it all still works
CRImier commented 6 years ago

Done - thanks to @monsieurh !