Skip to content
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

Python 3 cleanups #824

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Commits on Dec 14, 2023

  1. remove ancient "future" compatibility library for python2

    Ironically, for a package that was intended to provide portability
    between python2 and python3, it is broken with python 3.12. A better
    library to use in all cases is "six".
    
    However, mythtv requires python 3.8 for a while now. Using
    "future.standard_library" is a no-op other than costing a pointless
    import and being troublesome to actually install.
    
    The hacky copy of six.with_metaclass included in "future" is rewritten
    to use the pure python3 form of a metaclass.
    eli-schwartz committed Dec 14, 2023
    Configuration menu
    Copy the full SHA
    0efec84 View commit details
    Browse the repository at this point in the history
  2. automatically upgrade python code to python3

    Drop ancient and outdated backwards compatibility code designed to
    support python2, which is no longer supported anymore.
    
    Performed using the command:
    ```
    find . -name '*.py' -exec pyupgrade --py3-only --keep-percent-format {} +
    ```
    
    and committing the results.
    
    Mostly, this changes:
    - remove coding cookies
    - drop no-op imports of `__future__` or `builtins`
    - classes don't need to inherit object anymore
    - simpler `super()`
    - drop the no-op string prefix u''
    - drop some code under `sys.version_info == 2`. This never worked
      because it didn't compare to .major, but if it did work it would not
      be needed anymore on python 3.
    eli-schwartz committed Dec 14, 2023
    Configuration menu
    Copy the full SHA
    62d1919 View commit details
    Browse the repository at this point in the history
  3. manually port some version_info checks not caught by pyupgrade

    The bulk of this is to just manually unroll custom is_py3 checks and
    switch to the canonical python3 naming. If this had just used six, then
    this would be trivially automated...
    eli-schwartz committed Dec 14, 2023
    Configuration menu
    Copy the full SHA
    46cff64 View commit details
    Browse the repository at this point in the history