Improve type checks - #14036
Conversation
* upstream/main: Fix transition bandwidth reported in 'filter too short' error (mne-tools#11406) (mne-tools#14005)
|
Okay too many packages needed for type checking made |
|
A tiny bit of stuff here would get simpler if we dropped 3.10 support. 3.11 is actually almost out of SPEC0 so I don't mind dropping 3.10 now. But not too painful to keep it. It's EOL in October. |
|
nice to see these changes on type check improvement, @larsoner thanks for the work ❤️ , I tried to go through the pr to help with review but it includes many changes so i quit 😁 (leaving for members).
happy to help if needed, please feel free to ping 😊 |
* upstream/main: Make scrollbar handlers draggable (mne-tools#14040) [pre-commit.ci] pre-commit autoupdate (mne-tools#14052) Warn when Epochs events fall outside the raw data range (mne-tools#12989) (mne-tools#14004) Ensure epochs being concatenated have compatible event ids (mne-tools#14051) Widen main content area (mne-tools#14015) MAINT: remove dead gain/bits/value_range fields from _read_header in … (mne-tools#14047) ENH: replace `_get_blocks` binary reader with mffpy Reader API (mne-tools#14043) MAINT: Update dependency specifiers (mne-tools#14048) [dependabot]: Bump the actions group with 2 updates (mne-tools#14049) Simplify doc building with more refleak (mne-tools#14045) ENH: add overlay Brain GUI (mne-tools#14031) ENH: support multiple simultaneous overlays in Brain.add_data (mne-tools#13995) Add option to show a zero line in browser (mne-tools#14018) FIX: pass cmap name string not tuple to interactive topomap slider kwargs (mne-tools#14039) Doc/add ai policy pointer (mne-tools#14037) Allow subclasses of FigureClass to be passed to plot_raw/plot_epochs (mne-tools#13979) MAINT: Replace manual PNS binary block reader in `_read_segment_file` with `mffpy` (mne-tools#14030)
|
Okay this approach is working in several projects (mne-kit-gui, sphinx-gallery, etc.) and seems to be working here, so I'll go ahead and merge so that we don't get more and more conflicts! |
Resolve conflicts from the landed ty type-checker PR (mne-tools#14036) and intervening feature PRs: - CI (autofix.yml/tests.yml/azure-pipelines.yml): take upstream's canonical restructure (vulture moved into the autofix job, mypy->ty, style job removed); our preliminary CI edits were superseded. - Type-checker infra (_typing.py, test_docstring_parameters.py): keep our richer doc/api-scoped consistency checker (superset comparison, Color/FileLike pseudo-type aliases, Literal handling) which subsumes upstream's simpler one; add a `class`->`type` pseudo-type normalization for the new `figure_class`. - New upstream features merged with our annotations: `on_outside` on BaseEpochs/Epochs/EpochsArray, `show_zero_line`/`figure_class` on Raw.plot/Epochs.plot (annotated to match their numpydoc types). - egi: drop the now-dead `_block_r`/`_get_blocks` helpers and take upstream's `_get_mff_reader`-based PNS reader; keep our `_get_signalfname` assert fix. ty pre-commit hook, ruff, and test_type_hints_match_docstrings all pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* upstream/main: (206 commits) Improve type checks (mne-tools#14036) Make scrollbar handlers draggable (mne-tools#14040) [pre-commit.ci] pre-commit autoupdate (mne-tools#14052) Warn when Epochs events fall outside the raw data range (mne-tools#12989) (mne-tools#14004) Ensure epochs being concatenated have compatible event ids (mne-tools#14051) Widen main content area (mne-tools#14015) MAINT: remove dead gain/bits/value_range fields from _read_header in … (mne-tools#14047) ENH: replace `_get_blocks` binary reader with mffpy Reader API (mne-tools#14043) MAINT: Update dependency specifiers (mne-tools#14048) [dependabot]: Bump the actions group with 2 updates (mne-tools#14049) Simplify doc building with more refleak (mne-tools#14045) ENH: add overlay Brain GUI (mne-tools#14031) ENH: support multiple simultaneous overlays in Brain.add_data (mne-tools#13995) Add option to show a zero line in browser (mne-tools#14018) FIX: pass cmap name string not tuple to interactive topomap slider kwargs (mne-tools#14039) Doc/add ai policy pointer (mne-tools#14037) Allow subclasses of FigureClass to be passed to plot_raw/plot_epochs (mne-tools#13979) MAINT: Replace manual PNS binary block reader in `_read_segment_file` with `mffpy` (mne-tools#14030) Fix transition bandwidth reported in 'filter too short' error (mne-tools#11406) (mne-tools#14005) ENH: Show the current time as a vertical line in plot_evoked_topo (mne-tools#14032) ...
mypytoty, including as pre-commit astyis fast enough 🚀docstubbut let's use it here for a bit)mypymissed some stuff) and checking inepochs.py,evoked.py, andmne/ioio.read_raw_*, but keep theirdocs// website aliases pointing to publicly documented objectsdict[str, Any], 2)assert x is not Nonefor whenxisself._dataetc. (places where we know it is by code structure), plus using__getattr__and__setattr__to get*Bunchclasses to play nicelyctf/res4.pybecause type checkers have trouble with NumPy structured arraysinstance of RawEDFwhere we should have hadinstance of RawBDFprekin CIs instead ofpre-commit(pre-commit fails because our pre-commit env is too large now)Potential other things:
pre-committoprekif we wantedtyping_extensions)A follow-up PR can actually fully type hint the public functions + classes, but this is a (I'd argue necessary) prerequisite!
Used Claude Opus 4.8 to help me with the drudgery of
assert x is not Noneetc., but I also made a lot of changes myself, and understand + vouch for all code.Makes progress toward #12243