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

Add Python 3.12 related updates #110

Closed
wants to merge 1 commit into from

Conversation

arkid15r
Copy link

Resolves #109

Add Python 3.12 related updates:

  • Use Python 3.8-3.12 for test matrix
  • Bump GH action versions
  • Fix configparser SafeConfigParser name issue (the initial one)
  • Replace pkg_resources with importlib.metadata

The 3.12 test job will fail due to a similar issue -- I'll revisit this if needed later after malthe/chameleon#379 is addressed.

I also recommend migrating the PyPI publisher to OIDC's short lived tokens.

  - Use Python 3.8-3.12 for test matrix
  - Bump GH action versions
  - Fix configparser SafeConfigParser name issue (the initial one)
  - Replace pkg_resources with importlib.metadata
Copy link

@sallner sallner left a comment

Choose a reason for hiding this comment

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

Thanks for the work. I support those changes and would hope that they get merged and released soon.

Comment on lines 14 to 17
try:
from configparser import SafeConfigParser
from configparser import ConfigParser as SafeConfigParser
except ImportError:
from ConfigParser import SafeConfigParser
Copy link

Choose a reason for hiding this comment

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

As this is a pattern to support Python 2 it might as well be a good idea to just use the Python 3 variant.

Copy link
Author

Choose a reason for hiding this comment

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

Could you provide an example?

Copy link

Choose a reason for hiding this comment

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

Since lingua is Python 3 only, the except-case can be removed. The module is called configparser since Python 3.0.

Comment on lines +3 to +6
try:
from importlib.metadata import entry_points
except ImportError:
from importlib_metadata import entry_points
Copy link

Choose a reason for hiding this comment

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

To prevent the same issue as with configparser above, it could be helpful to document, when this workaround is no longer needed.

Copy link

Choose a reason for hiding this comment

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

Suggested change
try:
from importlib.metadata import entry_points
except ImportError:
from importlib_metadata import entry_points
try:
from importlib.metadata import entry_points
except ImportError: # required up to Python 3.9
from importlib_metadata import entry_points

At least AFAIU https://docs.python.org/3.9/library/importlib.metadata.html#entry-points and the "Compatibility Note" in https://docs.python.org/3.10/library/importlib.metadata.html#entry-points

Comment on lines +1 to +5
try:
from importlib.metadata import entry_points
except ImportError:
from importlib_metadata import entry_points

Copy link

Choose a reason for hiding this comment

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

See above.

Copy link
Author

@arkid15r arkid15r left a comment

Choose a reason for hiding this comment

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

Hi @sallner, thanks for reviewing this!

Comment on lines 14 to 17
try:
from configparser import SafeConfigParser
from configparser import ConfigParser as SafeConfigParser
except ImportError:
from ConfigParser import SafeConfigParser
Copy link
Author

Choose a reason for hiding this comment

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

Could you provide an example?

@arkid15r
Copy link
Author

I've bumped into one more lingua issue that needs to be fixed 🤷‍♂️

Taking into account there has been no activity on the project for more than 18 months it may be a good idea to branch out a new project and use it for further development. Need to look into the license for details. Keeping this open for another week or two.

Copy link

@htgoebel htgoebel left a comment

Choose a reason for hiding this comment

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

Thanks for this update.
@wichert Can you please merge this and provide a new release.Thanks.

@@ -9,15 +9,15 @@ jobs:

strategy:
matrix:
python: ["3.7", "3.9", "3.10"]
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
Copy link

Choose a reason for hiding this comment

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

I'd keep Python 3.7 if test still pass. Even if 3.7 is EOL there might be old code out there using it.

Comment on lines 14 to 17
try:
from configparser import SafeConfigParser
from configparser import ConfigParser as SafeConfigParser
except ImportError:
from ConfigParser import SafeConfigParser
Copy link

Choose a reason for hiding this comment

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

Since lingua is Python 3 only, the except-case can be removed. The module is called configparser since Python 3.0.

Comment on lines +3 to +6
try:
from importlib.metadata import entry_points
except ImportError:
from importlib_metadata import entry_points
Copy link

Choose a reason for hiding this comment

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

Suggested change
try:
from importlib.metadata import entry_points
except ImportError:
from importlib_metadata import entry_points
try:
from importlib.metadata import entry_points
except ImportError: # required up to Python 3.9
from importlib_metadata import entry_points

At least AFAIU https://docs.python.org/3.9/library/importlib.metadata.html#entry-points and the "Compatibility Note" in https://docs.python.org/3.10/library/importlib.metadata.html#entry-points

@arkid15r
Copy link
Author

Closing in favor of vacanza/lingva#1

@arkid15r arkid15r closed this Mar 20, 2024
@arkid15r arkid15r deleted the update-configparser branch March 20, 2024 17:40
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.

Python 3.12 configparser module name error
3 participants