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

fix init_parser_plugins for python 3.12 #425

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions lute/parse/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""

from importlib.metadata import entry_points
from sys import version_info

from lute.parse.base import AbstractParser
from lute.parse.space_delimited_parser import SpaceDelimitedParser, TurkishParser
Expand All @@ -24,13 +25,21 @@ def init_parser_plugins():
"""
Initialize parsers from plugins
"""
custom_parser_eps = entry_points().get("lute.plugin.parse", [])

if version_info.major == 3 and version_info.minor in (8, 9, 10, 11):
custom_parser_eps = entry_points().get('lute.plugin.parse')
elif version_info.major == 3 and version_info.minor == 12:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps we should change this to >= 12. Granted, we can't know what the API will be in version 3.13+, but maybe we can play fast and loose with this one, and just bump up the CI checks on GitHub as versions come out.

custom_parser_eps = entry_points().select(group='lute.plugin.parse')
else:
custom_parser_eps = None
if custom_parser_eps is None:
return
for custom_parser_ep in custom_parser_eps:
if _is_valid(custom_parser_ep.load()):
__LUTE_PARSERS__[custom_parser_ep.name] = custom_parser_ep.load()
else:
raise ValueError(
f"{custom_parser_ep.name} is not a subclass of AbstractParser"
f"{custom_parser_ep.name} is not a a subclass of AbstractParser"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I removed the "a a" before, and here it's added again, any reason? :-)

)


Expand Down
Loading