Conversation
… metrics The libyear dependency metrics collection would crash when processing Pipfiles with inline table (dict) dependency specifications. The code assumed all dependency values were strings, but Pipfile format allows dicts for complex specifications like extras, markers, and path dependencies. This commit: - Adds normalize_pipfile_version() to safely handle all Pipfile formats - Adds defensive type checks before string operations in downstream functions - Implements Pipfile.lock preference over Pipfile (more reliable) - Filters unsupported formats (path, editable) with debug logging - Adds 26 comprehensive unit tests - Includes reproduction script for verification Changes are backward compatible and use defensive programming to prevent future crashes. Valid dependencies continue to be processed; only unsupported formats (path, editable) are skipped with appropriate logging. Files modified: - augur/tasks/git/dependency_libyear_tasks/libyear_util/pypi_parser.py - augur/tasks/git/dependency_libyear_tasks/libyear_util/pypi_libyear_util.py - augur/tasks/git/dependency_libyear_tasks/libyear_util/util.py Files added: - tests/test_tasks/test_libyear_dependency_metrics.py (26 tests) - scripts/reproduce_issue_3430.py - tests/test_data/issue_3430_test_Pipfile - tests/test_data/REPRODUCTION_GUIDE.md Fixes #3430 Signed-off-by: Zeba Fatma Khan <khanz@rknec.edu>
| Tests specifically address issue #3430: Pipfile parsing failures with inline table dependencies. | ||
| """ | ||
| import pytest | ||
| import tempfile |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
W0611: Unused import tempfile (unused-import)
| """ | ||
| import pytest | ||
| import tempfile | ||
| import os |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
W0611: Unused import os (unused-import)
| import tempfile | ||
| import os | ||
| from io import BytesIO | ||
| import logging |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
W0611: Unused import logging (unused-import)
Contributor
Author
|
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.
Note
This PR was ported from augurlabs/augur#3495 filed by @zeba-source because the contribution was deemed to still be useful.
Summary
Fixes #143
The libyear dependency metrics collection would crash when processing Pipfiles
containing non-string values (such as booleans, dicts, or other TOML types).
The code assumed all values in dependency-related sections were strings and
would fail with "Expecting something like a string" when encountering values
like
allow_prereleases = true.Root Cause
The error occurred when the code iterated over Pipfile sections and attempted
string operations (regex matching, version parsing) on non-string values without
type checking.
Example from the failing Pipfile:
Changes Made
Core Fixes
normalize_pipfile_version()to safely handle all Pipfile value typesTesting
Files Modified
augur/tasks/git/dependency_libyear_tasks/libyear_util/pypi_parser.pyaugur/tasks/git/dependency_libyear_tasks/libyear_util/pypi_libyear_util.pyaugur/tasks/git/dependency_libyear_tasks/libyear_util/util.pyFiles Added
tests/test_tasks/test_libyear_dependency_metrics.py(26 tests)scripts/reproduce_issue_3430.pytests/test_data/issue_3430_test_Pipfiletests/test_data/REPRODUCTION_GUIDE.mdBackward Compatibility
Changes use defensive programming and are fully backward compatible. Valid
string dependencies continue to be processed normally; only non-string values
are skipped with appropriate logging.
AI disclosure
Yes, I used AI assistance (Claude/ChatGPT) to help with:
I reviewed all AI-generated code and tested it locally before submitting.