-
Notifications
You must be signed in to change notification settings - Fork 318
Split widget and introduce base enums #595
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
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
urwid/widget/constants.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
technically after enums introduction and move of sizing helpers it's not constants, but I have no idea about better naming
urwid/widget/wimp.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was lazy and not splitted this module: it's < 1000 LOC's and can be splitted later if will be too complex
urwid/listbox.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
automatically re-formatted after imports change (no manual work)
@@ -25,6 +26,7 @@ def test_connect(self): | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__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 (
widget
module), container widgets (container
module) and decoration widgets (decoration
andgraphics
modules) 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
master
orpython-dual-support
branchtox
successfully in local environment