Fix bugs and code quality issues found during audit#28
Merged
Conversation
form.py: - fetch_data: fix inconsistent return — error path now stores empty DataFrame in self.data instead of returning it; return type -> None - fetch_data: use None (object dtype) for missing survey columns so pandas 3.0 does not reject string assignment on the empty slice - fetch_media: fix AttributeError — media is a list at the .empty check; build the DataFrame first, then check .empty on it; also fix media.metadata -> self.media["metadata"] - _get_survey: use `is None` guard instead of falsy check so an empty dict asset does not bypass the cache - _fetch_asset: call res.json() once and reuse the result - _split_gps_coords: fix repeat-group path using list.append(a, b) (TypeError) -> list.insert(a, b) - remove now-unused `from typing import Union` manager.py: - _fetch_forms: fix return type annotation None -> list - get_forms / get_form: use `is None` cache guard so an account with zero forms does not re-fetch on every call - upload_media_from_local: normalise file extension to lowercase and drop the mixed-case duplicate entries (.JPGE typo, .JPG, .PNG); fix unclosed file handle by wrapping open() in a with-block - _upload_media: remove res.status_code mutation to seed the while-loop; use while True / break pattern instead utility.py: - reconcile_columns_append: replace TODO/XXX placeholder docstring tests/test_form.py: - update test_fetch_data_api_error to check f.data instead of return value Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
form.py:
is Noneguard instead of falsy check so an empty dict asset does not bypass the cachefrom typing import Unionmanager.py:
is Nonecache guard so an account with zero forms does not re-fetch on every callutility.py:
tests/test_form.py: