Repository navigation
Ensure that backend names are valid Python identifiers - #8160
Merged
Merged
Conversation
amcandio
approved these changes
Jul 22, 2025
amcandio
left a comment
Contributor
There was a problem hiding this comment.
Thanks! Left a minor suggestion but this looks good to me
rossbar
approved these changes
Jul 22, 2025
Co-authored-by: Alejandro Candioti <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In #8115, a user encountered an error when a backend name was not a valid Python identifier.
@amcandio suggested we guard against this #8115 (comment).
Notably, it's possible for users to encounter this when e.g.
networkx.egg-info/entry_points.txtfile has an old entry fornx-loopbackinstead ofnx_loopback, as may have happened in #8115.This PR ignores backends that are not valid identifiers, displays a warning when this happens, and updates documentation to indicate that backends must be valid Python identifiers.
Instead of checking when creating the config as suggested in #8115 (comment), this PR checks when loading the entry points for backends.
If an invalidly named backend uses both
networkx.backendsandnetworkx.backend_infoentry points, two warnings will be issued.