Skip to content

Fix type-safety diagnostics in validate_implementations.py - #118

Merged
neuromechanist merged 2 commits into
mainfrom
issue-117-typing-diagnostics
Jul 13, 2026
Merged

neuromechanist merged 2 commits into
mainfrom
issue-117-typing-diagnostics

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Closes #117.

  • run_fortran_amica returns None on several early-exit paths but was typed
    -> Dict; retyped -> Optional[Dict] to match reality (callers already
    handle Optional[Dict] via compare_results).
  • os/original_dir were only assigned inside the try: block but read in
    the except: branches (possibly-unbound); hoisted import os to the
    top-level imports and original_dir = os.getcwd() before the try:.
  • load_eeglab_data's dtype: np.dtype = np.float32 default didn't match its
    own annotation (np.float32 is a scalar type, not an np.dtype instance);
    widened to npt.DTypeLike.

Verified false positives, left as-is: the torch/scipy.optimize "could not
be resolved" diagnostics are a Pyright/IDE environment issue -- both resolve
and import fine at runtime (uv run python -c "import torch, scipy").

Test plan

  • uv run ty check validate_implementations.py pyAMICA/torch_impl/utils.py passes
  • uv run ruff check / ruff format --check pass
  • uv run pytest pyAMICA/tests/test_fortran_adapter.py pyAMICA/tests/torch_tests/test_ng_utils.py passes (20 passed, 3 skipped)

run_fortran_amica returns None on several paths but was typed -> Dict;
os/original_dir were possibly-unbound in except blocks since they were
only assigned inside the try; load_eeglab_data's dtype default didn't
match its own annotation.
@neuromechanist neuromechanist linked an issue Jul 13, 2026 that may be closed by this pull request
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.76%. Comparing base (ed0bd0a) to head (3101a75).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #118      +/-   ##
==========================================
+ Coverage   79.75%   79.76%   +0.01%     
==========================================
  Files          14       14              
  Lines        2010     2011       +1     
  Branches      339      339              
==========================================
+ Hits         1603     1604       +1     
  Misses        301      301              
  Partials      106      106              
Files with missing lines Coverage Δ
pyAMICA/torch_impl/utils.py 59.30% <100.00%> (+0.47%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@neuromechanist
neuromechanist merged commit bc330bc into main Jul 13, 2026
5 checks passed
@neuromechanist
neuromechanist deleted the issue-117-typing-diagnostics branch July 13, 2026 21:50
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.

validate_implementations.py: fix type-safety diagnostics

2 participants