Skip to content

Fix bugs and code quality issues found during audit#28

Merged
pvernier merged 1 commit intomainfrom
fix-bugs-and-improvements
Mar 26, 2026
Merged

Fix bugs and code quality issues found during audit#28
pvernier merged 1 commit intomainfrom
fix-bugs-and-improvements

Conversation

@pvernier
Copy link
Copy Markdown
Owner

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

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>
@pvernier pvernier merged commit c2fc76f into main Mar 26, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant