-
* inline version comparison checks Assigning global constants for sys.version_info comparisons makes it hard to run automatic migrations. * automatically upgrade code to drop python2-specific Klass(object) part 1 Ported by running the following command: ``` ruff check eventlet/ --select UP004 --fix ``` and committing the results. * automatically upgrade code to drop python2-specific super(), part 1 Ported by running the following command: ``` ruff check eventlet/ --select UP008 --fix --unsafe-fixes ``` fixing a couple of resulting pycodestyle indent issues, and committing the results. * automatically upgrade code to drop python2-specific coding cookie part 1 Ported by running the following command: ``` ruff check eventlet/ --select UP009 --fix ``` and committing the results. * automatically upgrade code to drop python2-specific future import part 1 Ported by running the following command: ``` ruff check eventlet/ --select UP010 --fix ``` and committing the results. * automatically upgrade code to drop python2-specific exceptions, part 1 Ported by running the following command: ``` ruff check eventlet/ --select UP024 --fix ``` and committing the results. * automatically upgrade code to drop python2 format placeholders, part 1 Ported by running the following command: ``` ruff check eventlet/ --select UP030 --fix --unsafe-fixes ``` and committing the results. * automatically upgrade code to drop python2-specific imports, part 1 Ported by running the following command: ``` ruff check eventlet/ --select UP035 --fix ``` and realizing that it was already try/excepted. The automatic rewriter doesn't notice the difference, but we do. Manually fix this up, and commit it. * automatically upgrade remaining code to drop python2-specific logic, part 1 Ported by running the following command: ``` find eventlet -name '*.py' -exec pyupgrade --py3-only --keep-percent-format {} + ``` fixing a couple of resulting pycodestyle indent/spacing issues, and committing the results. Touch only the primary project code for now. Clean up the tests etc. later. This covers a few different types of fixes: - collapse various six imports to their canonical python3 location - elide or collapse various six.PY2 / six.PY3 conditional code to unconditionally, exclusively, run the latter - catch some OSError conversions that ruff did not catch, because of `__import__()` - rewrite set/dict to literals - directly use dict methods (.keys, .items, ...) instead of py2-wrapper .iter - mark strings as raw if they have invalid escape sequences * manually clean up a lot of remaining "import six" code, part 1 Touch only the eventlet/ directory. Manual cleanups to follow. Variously: - simply drop an unused import - convert six.StringIO to io.StringIO - convert six.b() to encoding string -> bytes - collapsing six.moves or six.PY2 logic too complex for the rewriter * Drop remaining python < 3.7 compatible legacy code, part 1 Automatically migrated by running: ``` ruff check eventlet/ --select UP036 --fix --unsafe-fixes ``` and committing the results. Touch only eventlet/ for now. This implements one fixer: - code guarded by sys.version_info conditional on a target python of py37 * automatically upgrade code to drop python2-specific Klass(object) part 2 Ported by running the following command: ``` ruff check . --select UP004 --fix ``` and committing the results. * automatically upgrade code to drop python2.6-specific unittest method Ported by running the following command: ``` ruff check . --select UP005 --fix ``` fixing a couple of resulting pycodestyle indent issues, and committing the results. * automatically upgrade code to drop python2-specific super(), part 2 Ported by running the following command: ``` ruff check . --select UP008 --fix --unsafe-fixes ``` and committing the results. * automatically upgrade code to drop python2-specific coding cookie part 2 Ported by running the following command: ``` ruff check . --select UP009 --fix ``` and committing the results. * automatically upgrade code to drop python2-specific future import part 2 Ported by running the following command: ``` ruff check . --select UP010 --fix ``` and committing the results. * automatically upgrade code to drop python2 encode of string literal Ported by running the following command: ``` ruff check . --select UP012 --fix ``` and committing the results. * automatically upgrade code to drop python2-specific open mode Ported by running the following command: ``` ruff check . --select UP015 --fix ``` and committing the results. * automatically upgrade code to drop python2-specific io.open alias Ported by running the following command: ``` ruff check . --select UP020 --fix ``` and committing the results. * automatically upgrade code to drop python2-specific exceptions, part 2 Ported by running the following command: ``` ruff check . --select UP024 --fix ``` fixing a couple of resulting pycodestyle indent/spacing issues, and committing the results. * automatically upgrade code to drop python2-specific u string prefix Ported by running the following command: ``` ruff check . --select UP025 --fix ``` and committing the results. * automatically upgrade code to drop python2-specific yield loop Ported by running the following command: ``` ruff check . --select UP028 --fix ``` and committing the results. * automatically upgrade code to drop python2 format placeholders, part 2 Ported by running the following command: ``` ruff check . --select UP030 --fix --unsafe-fixes ``` and committing the results. * automatically upgrade remaining code to drop python2-specific logic, part 2 Ported by running the following command: ``` find . -name '*.py' -exec pyupgrade --py3-only --keep-percent-format {} + ``` fixing a couple of resulting pycodestyle indent/spacing issues, and committing the results. Clean up the rest of the non eventlet/ code. This covers a few different types of fixes: - collapse various six imports to their canonical python3 location - elide or collapse various six.PY2 / six.PY3 conditional code to unconditionally, exclusively, run the latter - catch some OSError conversions that ruff did not catch, because of `__import__()` - rewrite set/dict to literals - directly use dict methods (.keys, .items, ...) instead of py2-wrapper .iter - mark strings as raw if they have invalid escape sequences * manually clean up a lot of remaining "import six" code, part 2 Clean up all remaining code outside of eventlet/ itself. Variously: - simply drop an unused import - convert six.StringIO to io.StringIO - convert six.b() to encoding string -> bytes - collapsing six.moves or six.PY2 logic too complex for the rewriter * Drop remaining python < 3.7 compatible legacy code, part 2 Automatically migrated by running: ``` ruff check . --select UP036 --fix --unsafe-fixes ``` and committing the results. Clean up all remaining code outside of eventlet/ itself. This implements one fixer: - code guarded by sys.version_info conditional on a target python of py37 * Restore to correct code (matching the version in stdlib) --------- Co-authored-by:
Itamar Turner-Trauring <itamar@itamarst.org> Co-authored-by:
Itamar Turner-Trauring <itamar@pythonspeed.com>
* inline version comparison checks Assigning global constants for sys.version_info comparisons makes it hard to run automatic migrations. * automatically upgrade code to drop python2-specific Klass(object) part 1 Ported by running the following command: ``` ruff check eventlet/ --select UP004 --fix ``` and committing the results. * automatically upgrade code to drop python2-specific super(), part 1 Ported by running the following command: ``` ruff check eventlet/ --select UP008 --fix --unsafe-fixes ``` fixing a couple of resulting pycodestyle indent issues, and committing the results. * automatically upgrade code to drop python2-specific coding cookie part 1 Ported by running the following command: ``` ruff check eventlet/ --select UP009 --fix ``` and committing the results. * automatically upgrade code to drop python2-specific future import part 1 Ported by running the following command: ``` ruff check eventlet/ --select UP010 --fix ``` and committing the results. * automatically upgrade code to drop python2-specific exceptions, part 1 Ported by running the following command: ``` ruff check eventlet/ --select UP024 --fix ``` and committing the results. * automatically upgrade code to drop python2 format placeholders, part 1 Ported by running the following command: ``` ruff check eventlet/ --select UP030 --fix --unsafe-fixes ``` and committing the results. * automatically upgrade code to drop python2-specific imports, part 1 Ported by running the following command: ``` ruff check eventlet/ --select UP035 --fix ``` and realizing that it was already try/excepted. The automatic rewriter doesn't notice the difference, but we do. Manually fix this up, and commit it. * automatically upgrade remaining code to drop python2-specific logic, part 1 Ported by running the following command: ``` find eventlet -name '*.py' -exec pyupgrade --py3-only --keep-percent-format {} + ``` fixing a couple of resulting pycodestyle indent/spacing issues, and committing the results. Touch only the primary project code for now. Clean up the tests etc. later. This covers a few different types of fixes: - collapse various six imports to their canonical python3 location - elide or collapse various six.PY2 / six.PY3 conditional code to unconditionally, exclusively, run the latter - catch some OSError conversions that ruff did not catch, because of `__import__()` - rewrite set/dict to literals - directly use dict methods (.keys, .items, ...) instead of py2-wrapper .iter - mark strings as raw if they have invalid escape sequences * manually clean up a lot of remaining "import six" code, part 1 Touch only the eventlet/ directory. Manual cleanups to follow. Variously: - simply drop an unused import - convert six.StringIO to io.StringIO - convert six.b() to encoding string -> bytes - collapsing six.moves or six.PY2 logic too complex for the rewriter * Drop remaining python < 3.7 compatible legacy code, part 1 Automatically migrated by running: ``` ruff check eventlet/ --select UP036 --fix --unsafe-fixes ``` and committing the results. Touch only eventlet/ for now. This implements one fixer: - code guarded by sys.version_info conditional on a target python of py37 * automatically upgrade code to drop python2-specific Klass(object) part 2 Ported by running the following command: ``` ruff check . --select UP004 --fix ``` and committing the results. * automatically upgrade code to drop python2.6-specific unittest method Ported by running the following command: ``` ruff check . --select UP005 --fix ``` fixing a couple of resulting pycodestyle indent issues, and committing the results. * automatically upgrade code to drop python2-specific super(), part 2 Ported by running the following command: ``` ruff check . --select UP008 --fix --unsafe-fixes ``` and committing the results. * automatically upgrade code to drop python2-specific coding cookie part 2 Ported by running the following command: ``` ruff check . --select UP009 --fix ``` and committing the results. * automatically upgrade code to drop python2-specific future import part 2 Ported by running the following command: ``` ruff check . --select UP010 --fix ``` and committing the results. * automatically upgrade code to drop python2 encode of string literal Ported by running the following command: ``` ruff check . --select UP012 --fix ``` and committing the results. * automatically upgrade code to drop python2-specific open mode Ported by running the following command: ``` ruff check . --select UP015 --fix ``` and committing the results. * automatically upgrade code to drop python2-specific io.open alias Ported by running the following command: ``` ruff check . --select UP020 --fix ``` and committing the results. * automatically upgrade code to drop python2-specific exceptions, part 2 Ported by running the following command: ``` ruff check . --select UP024 --fix ``` fixing a couple of resulting pycodestyle indent/spacing issues, and committing the results. * automatically upgrade code to drop python2-specific u string prefix Ported by running the following command: ``` ruff check . --select UP025 --fix ``` and committing the results. * automatically upgrade code to drop python2-specific yield loop Ported by running the following command: ``` ruff check . --select UP028 --fix ``` and committing the results. * automatically upgrade code to drop python2 format placeholders, part 2 Ported by running the following command: ``` ruff check . --select UP030 --fix --unsafe-fixes ``` and committing the results. * automatically upgrade remaining code to drop python2-specific logic, part 2 Ported by running the following command: ``` find . -name '*.py' -exec pyupgrade --py3-only --keep-percent-format {} + ``` fixing a couple of resulting pycodestyle indent/spacing issues, and committing the results. Clean up the rest of the non eventlet/ code. This covers a few different types of fixes: - collapse various six imports to their canonical python3 location - elide or collapse various six.PY2 / six.PY3 conditional code to unconditionally, exclusively, run the latter - catch some OSError conversions that ruff did not catch, because of `__import__()` - rewrite set/dict to literals - directly use dict methods (.keys, .items, ...) instead of py2-wrapper .iter - mark strings as raw if they have invalid escape sequences * manually clean up a lot of remaining "import six" code, part 2 Clean up all remaining code outside of eventlet/ itself. Variously: - simply drop an unused import - convert six.StringIO to io.StringIO - convert six.b() to encoding string -> bytes - collapsing six.moves or six.PY2 logic too complex for the rewriter * Drop remaining python < 3.7 compatible legacy code, part 2 Automatically migrated by running: ``` ruff check . --select UP036 --fix --unsafe-fixes ``` and committing the results. Clean up all remaining code outside of eventlet/ itself. This implements one fixer: - code guarded by sys.version_info conditional on a target python of py37 * Restore to correct code (matching the version in stdlib) --------- Co-authored-by:
Itamar Turner-Trauring <itamar@itamarst.org> Co-authored-by:
Itamar Turner-Trauring <itamar@pythonspeed.com>
websocket.py 1.19 KiB