Skip to content

Remove Python2 compatibility #480

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

soulee-dev
Copy link
Contributor

In this PR, we have removed the compatibility with Python 2 to streamline the code and leverage the features of Python 3 more fully. The specific changes include the following:

  • Removed # -*- coding: utf-8 -*- from the top of Python files, as Python 3 assumes UTF-8 encoding by default.
  • Eliminated conditional imports that checked sys.version_info to import different modules or packages based on the Python version.
  • Deleted _compat.py file which was used to handle string type differences between Python 2 and 3.

Changes

  1. Removal of UTF-8 encoding declarations

    Python 3 assumes UTF-8 encoding by default, so it's safe to remove # -*- coding: utf-8 -*- declarations from all files.

  2. Unification of imports

    Removed conditional imports that were dependent on the Python version. Now, all imports are unified to be compatible with Python 3.

    For instance, the following conditional import:

    if sys.version_info < (2, 7):
        import unittest2 as unittest
    else:
        import unittest

    Has been updated to simply:

    import unittest
  3. Deletion of _compat.py

    We removed the _compat.py file, which was primarily used to handle string type differences between Python 2 and 3. With this change, we are standardizing on the Python 3 string type.

@julien-duponchelle julien-duponchelle merged commit a4e59d6 into julien-duponchelle:main Sep 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants