diff options
author | Alexey Stepanov <penguinolog@users.noreply.github.com> | 2023-03-31 17:08:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-31 17:08:50 +0200 |
commit | ea7e615ef5ee0897f66210f47ab6390889d7b313 (patch) | |
tree | d627570bacd90fb347f684c76c52b6c1065a9c41 /docs/tutorial/sig.py | |
parent | 07621f1c8cc8bd88e55a3c3e48861c65f293b3f1 (diff) | |
download | urwid-ea7e615ef5ee0897f66210f47ab6390889d7b313.tar.gz |
Python 37+ initial migration (#522)
* Initial migration to the python 3.7: Semi-automatic changes
CI related:
Update `tox.ini` and `.travis.yml` to run python3 only tests
Python 3.11 tests is commented-out on travis until #517 is not merged
Manual changes:
* `setup.py`: classifiers, remove python2 compatibility code
* `docs/manual/wcur2.py`: looks like file was never completed, syntax is invalid
* `urwid.compat`: removed `ord2`, `bytes3`, `text_type`, `xrange` and `text_types`
Automatic changes (no manual editing, AST validated equality:
* removed `u` prefix from all strings: not allowed in modern python code
* `bytes()` -> `b''`
* `== None` -> `is None`
* subclassing of `object`
* `super(<Class>`, self>)` ->`super()`
* `from __future__ import ...` python3 compatibility imports
* `set(<Iterable[Hashable]>)` -> `{<Hashable>}`
* partial f-strings conversion
* (`IOError`, `select.error`, `socket.error`) -> `OSError`
* Switch to f-strings (automatic changes)
* Remove `urwid.compat.B`
* Remove `urwid.compat.with_metaclass`
* use native `super()` instead of `self.__super`
* Remove `urwid.compat.chr2`
* Remove `urwid.split_repr.python3_repr`
* Use native `@classmethod` and `@property` where overload is not possible
* Add `from __future__ import annotations`
* automatically sort imports
* Add DeprecationWarning to the deprecated methods
most IDE's will recognize it and annotate during new code usage
call with "warnings as errors" mode will help to refactor other users
* Address comments
* replace homepage address in all files
* remove outdated comments in compat.py
* make wcur2.py correct python code. For example subclass
* replace `self.__super` by `super()` in examples
* fix asyncio_socket_server.py: magic with `asyncio` became wrong
* Remove `widget.update_wrapper`: this was backport of python `functools.update_wrapper`
* display_common.py: fix trivial typo in _colors calculation
* use `sorted` method instead of list construction with later sorting
* Address comments
* `wcur2` include in docs
* warning on `signals.Signals.emit`
---------
Co-authored-by: Aleksei Stepanov <alekseis@nvidia.com>
Diffstat (limited to 'docs/tutorial/sig.py')
-rw-r--r-- | docs/tutorial/sig.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/docs/tutorial/sig.py b/docs/tutorial/sig.py index c01c1b2..383553e 100644 --- a/docs/tutorial/sig.py +++ b/docs/tutorial/sig.py @@ -1,15 +1,17 @@ +from __future__ import annotations + import urwid palette = [('I say', 'default,bold', 'default', 'bold'),] -ask = urwid.Edit(('I say', u"What is your name?\n")) -reply = urwid.Text(u"") -button = urwid.Button(u'Exit') +ask = urwid.Edit(('I say', "What is your name?\n")) +reply = urwid.Text("") +button = urwid.Button('Exit') div = urwid.Divider() pile = urwid.Pile([ask, div, reply, div, button]) top = urwid.Filler(pile, valign='top') def on_ask_change(edit, new_edit_text): - reply.set_text(('I say', u"Nice to meet you, %s" % new_edit_text)) + reply.set_text(('I say', f"Nice to meet you, {new_edit_text}")) def on_exit_clicked(button): raise urwid.ExitMainLoop() |