Skip to content

refactor(parameters): widen API return types from dict[str, int] to dict[str, Any] #159

Description

@MAfarrag

Context

PR #149 added `| None` to Figshare API return types but kept the
overly narrow `dict[str, int]` value type. The type-design-analyzer
and code-reviewer both flagged this.

Problem / Current Behaviour

Figshare API responses contain strings, lists, nested dicts, booleans,
and integers. The current `dict[str, int]` annotation is misleading
and causes downstream type issues (e.g., `list_article_versions`
needs `# type: ignore[return-value]`).

Additionally, `ParameterManager.get_parameter_set_details` can return
`None` but some callers (e.g., `download_files`) don't guard against
it.

Affected locations

File Symbol Notes
`src/Hapi/parameters/parameters.py:59` `send_request` Returns `dict[str, int] | None`
`src/Hapi/parameters/parameters.py:92` `get_article_version` Same
`src/Hapi/parameters/parameters.py:116` `list_article_versions` Returns `list[dict]`
`src/Hapi/parameters/parameters.py:297` `get_parameter_set_details` Returns `dict | None`
`src/Hapi/parameters/parameters.py:351` `download_files` Calls details without None guard

Proposed Solution

  1. Change return types to `dict[str, Any] | None`
  2. Add None guards in `download_files` and other callers
  3. Remove `# type: ignore[return-value]` from `list_article_versions`

Effort Estimate

Size: `S`

Definition of Done

  • All API return types use `dict[str, Any]` instead of `dict[str, int]`
  • All callers guard against `None` returns
  • No `# type: ignore[return-value]` needed
  • mypy passes

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions