Skip to content

Python 37+ initial migration - #522

Merged
penguinolog merged 14 commits into
urwid:masterfrom
penguinolog:py_37_migration
Mar 31, 2023
Merged

penguinolog merged 14 commits into
urwid:masterfrom
penguinolog:py_37_migration

Conversation

@penguinolog

Copy link
Copy Markdown
Collaborator
Checklist
  • I've ensured that similar functionality has not already been implemented
  • I've ensured that similar functionality has not earlier been proposed and declined
  • I've branched off the master or python-dual-support branch
  • I've merged fresh upstream into my branch recently
  • I've ran tox successfully in local environment

Related #394

@penguinolog penguinolog changed the title Python 37+ initia; migration Python 37+ initial migration Mar 28, 2023
@penguinolog penguinolog mentioned this pull request Mar 28, 2023
4 tasks done
@penguinolog

Copy link
Copy Markdown
Collaborator Author

rebased over test fixes PR

@penguinolog
penguinolog requested review from ulidtko and wardi March 28, 2023 20:17
@penguinolog
penguinolog force-pushed the py_37_migration branch 2 times, most recently from 8a3307e to 2e872d4 Compare March 29, 2023 08:09
Comment thread .travis.yml
@@ -1,19 +1,17 @@
language: python
dist: bionic
#dist: bionic

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use actual default (BTW better to sunset Travis)

Comment thread docs/manual/wcur2.py

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like never completed file, syntax is incorrect

Comment thread docs/manual/wcur2.py Outdated
# def move_cursor_to_coords(self, (maxcol,), col, row):
# assert row == 0
# self.cursor_x = col
# return True

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commenting out manual examples?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem, that it's part of class copy-paste without class declaration -> this code causes parsing error

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't the manual use line ranges from examples? We could put a class above to avoid the parsing error instead of turning the code into comments

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made fake class

Comment thread examples/asyncio_socket_server.py Resolved
Comment thread examples/asyncio_socket_server.py Resolved
Comment thread urwid/curses_display.py Resolved
Comment thread urwid/web_display.py Resolved
@wardi

wardi commented Mar 29, 2023

Copy link
Copy Markdown
Collaborator

Added my comments. Some good changes here but mostly code reformatting.

Comment thread urwid/compat.py Resolved
@penguinolog

Copy link
Copy Markdown
Collaborator Author

Added my comments. Some good changes here but mostly code reformatting.

Addressed all

Comment thread urwid/display_common.py
return 256
if self._value & (_BG_TRUE_COLOR | _FG_TRUE_COLOR):
return 2**24
if self._value & (_BG_BASIC_COLOR | _BG_BASIC_COLOR):

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trivial typo

Comment thread docs/manual/wcur2.py
def move_cursor_to_coords(self, size, col, row):
assert row == 0
self.cursor_x = col
return True

@wardi wardi Mar 31, 2023 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like in docs/manual/widgets.rst where wcur2.py is referenced we can add a :lines: 7- to skip the first 6 lines of this file in the docs https://devopstutodoc.readthedocs.io/en/stable/documentation/doc_generators/sphinx/rest_sphinx/code/literalinclude/literalinclude.html#lines-xxx

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Validated build.
Had to merge another PR (#424) due to broken documentation build in master (Issue #509)

@wardi

wardi commented Mar 31, 2023

Copy link
Copy Markdown
Collaborator

Since some of these changes affect the docs, try regenerating the docs to see if any unintended changes appear

CI related:
Update `tox.ini` and `.travis.yml` to run python3 only tests
Python 3.11 tests is commented-out on travis until urwid#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`
* use native `super()` instead of `self.__super`
* automatically sort imports
most IDE's will recognize it and annotate during new code usage
call with "warnings as errors" mode will help to refactor other users
* 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
* `wcur2` include in docs
* warning on `signals.Signals.emit`
@wardi

wardi commented Mar 31, 2023

Copy link
Copy Markdown
Collaborator

@penguinolog I don't have any other comments

@penguinolog

Copy link
Copy Markdown
Collaborator Author

Merging

@penguinolog
penguinolog merged commit ea7e615 into urwid:master Mar 31, 2023
@penguinolog
penguinolog deleted the py_37_migration branch March 31, 2023 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants