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

DeprecationWarning: SelectableGroups dict interface #1631

Closed
jclerman opened this issue Dec 29, 2021 · 2 comments · Fixed by #1694
Closed

DeprecationWarning: SelectableGroups dict interface #1631

jclerman opened this issue Dec 29, 2021 · 2 comments · Fixed by #1694

Comments

@jclerman
Copy link
Contributor

jclerman commented Dec 29, 2021

When running pytest on a project that includes rdflib as a dependency, I am seeing the following warning:

<my venv path>/lib/python3.7/site-packages/rdflib/plugins/sparql/__init__.py:52
  <my venv path>/lib/python3.7/site-packages/rdflib/plugins/sparql/__init__.py:52: DeprecationWarning: SelectableGroups dict interface is deprecated. Use select.
    for ep in all_entry_points.get(PLUGIN_ENTRY_POINT, []):

Looks like the problematic code is lines 50 onward, in rdflib/plugins/sparql/__init__.py. To avoid the deprecation warning, it'd be better to use the new interface if it's available, and only call the deprecated one if necessary. My suggestion (I'm just changing the if/elif/else conditions and adding an "else" condition which should never be reached; the remaining code is unchanged from the original):

all_entry_points = entry_points()
if hasattr(all_entry_points, 'select') and callable(all_entry_points.select):
    for ep in all_entry_points.select(group=PLUGIN_ENTRY_POINT):
        CUSTOM_EVALS[ep.name] = ep.load()
elif isinstance(all_entry_points, dict):
    # Prior to Python 3.10, this returns a dict instead of the selection interface
    for ep in all_entry_points.get(PLUGIN_ENTRY_POINT, []):
        CUSTOM_EVALS[ep.name] = ep.load()
else:
    raise RuntimeError("entry_points() returned an object lacking either a select() method or a Dict interface")
@jclerman
Copy link
Contributor Author

Update:

Looks like the following line triggers the warning in rdflib 6.1.1, under python 3.7:

from rdflib.plugins.sparql.parser import parseUpdate

When running that with python3.7 -W error, a stack trace is generated showing the warning.

@aucampia
Copy link
Member

thanks for the info @jclerman - sorry I accidentally deleted the comment asking for it.

@aucampia aucampia self-assigned this Jan 23, 2022
@aucampia aucampia removed their assignment Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants