Repository navigation
Split widget and introduce base enums - #595
Conversation
* Backward compatible (subclass `str`) * Auto-format and static check for widget
* Backward compatible (subclass `str`)
* Use enums * Enforce code style and static checking
* Use backward compatible exports in package
* import to old modules for backward compatibility * split constants from widget module and extend WHSettings (CLIP = WrapMode.CLIP, FLOW = Sizing.FLOW) * proper normalize_*, simplify_* (check for None, partial handle `RELATIVE`)
* use backward compatibility imports in module
* use backward compatibility imports in module * leave python logo widget untouched
87f03e9 to
838b4e6
Compare
There was a problem hiding this comment.
technically after enums introduction and move of sizing helpers it's not constants, but I have no idea about better naming
There was a problem hiding this comment.
I was lazy and not splitted this module: it's < 1000 LOC's and can be splitted later if will be too complex
There was a problem hiding this comment.
automatically re-formatted after imports change (no manual work)
| edit.set_edit_text('another text') | ||
| handler.assert_not_called() | ||
|
|
||
| @unittest.skipIf(sys.implementation.name == "pypy", "WeakRef works differently on PyPy") |
There was a problem hiding this comment.
this test is expecially unstable on local PyPy run.
Also manual experiments shown, that everything garbage collector related work can work differently on PyPy
| urwid.widget, | ||
| urwid.wimp, | ||
| urwid.decoration, | ||
| urwid.widget.attr_map, |
There was a problem hiding this comment.
doctests need explicit paths :(
|
Validated compatibility against downstream packages: khal and zulip-terminal |
| VAlign, | ||
| WHSettings, | ||
| WrapMode, | ||
| normalize_align, |
There was a problem hiding this comment.
normalize_* / simplify_* are useful in downstream code, but was never exported "public"
| from .widget_decoration import WidgetDecoration, WidgetDisable, WidgetPlaceholder | ||
| from .wimp import Button, CheckBox, CheckBoxError, RadioButton, SelectableIcon | ||
|
|
||
| __all__ = ( |
There was a problem hiding this comment.
__all__ needed due to backwards-compatibility constants definition (as it's not used locally, it's defined as "public" explicit)
|
"clip" no longer works for the width parameter to The root cause is that Note that the following example program will print The fix is to assign The consequence at the moment is that release 2.2.0 can't be used in programs that use |
|
Using the |
|
On python 3.10 synthetic tests it also worked, but release is for python 3.7+ - need to fix now and wait for old python releases EOL. |
|
Further explanation: When a type is mixed in to an enum, that type is used to generate the Having said that, using one enum member as the value of another enum member is not intended, and can easily cause confusion: import enum
class OtherTest(enum.StrEnum):
CLIP = "clip"
class Test(enum.StrEnum):
PACK = "pack"
CLIP = OtherTest.CLIP
"clip" in (Test.PACK, Test.CLIP))
# True
Test.CLIP == OtherTest.CLIP
# True
Test.CLIP is OtherTest.CLIP # given the above definition, one could expect this to be True
# False |
Split base widget (
widgetmodule), container widgets (containermodule) and decoration widgets (decorationandgraphicsmodules) into several modules under subpackagewidget.Introduce string-compatible enums for sizing, align, valign, wrap mode and base width-height settings.
Enforce automating imports sorting and code formatting + static validation for introduced changes.
Checklist
masterorpython-dual-supportbranchtoxsuccessfully in local environment