Repository navigation
Fix ImportError in gflanguages.udhr after the move to gfmetadata - #276
Merged
simoncozens merged 1 commit intoSep 28, 2026
Merged
Conversation
Since 027fa61 ("Use gfmetadata, comprehensive GH action", released in 0.7.8) the generated protobuf modules live in gfmetadata and gflanguages no longer ships languages_public_pb2. __init__.py was updated, but gflanguages/udhr.py still does from gflanguages import languages_public_pb2 so importing the module fails: >>> import gflanguages.udhr ImportError: cannot import name 'languages_public_pb2' from 'gflanguages' Import it from gfmetadata instead, and do the same in the snippets that carry the old import. Add a test that imports gflanguages.udhr, since nothing in the test suite imported it before.
Contributor
|
Oops - thank you! |
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.
Since 0.7.8 (#260) the protobuf modules come from
gfmetadata, andgflanguagesno longer shipslanguages_public_pb2.Lib/gflanguages/udhr.pywas not updated and still imports it fromgflanguages, so the module can't be imported in 0.7.8 through 0.7.11:The existing tests didn't catch this because none of them import
gflanguages.udhr.This PR:
languages_public_pb2fromgfmetadatainudhr.py;snippets/that had the old import (add-all-scripts.py,fill_sample.py,fix-exemplars-bases.py,fix-exemplars-duplicates.py,lang_sample_text.py);test_udhr_importabletotests/test_gflanguages_api.py.Tested with gfmetadata 0.2.5: the new test fails without the fix and passes with it, and the full test suite passes.
black --checkis clean.I ran into this while updating the Debian package of gflanguages to 0.7.11.