Skip to content

Type improvement - #13671

Closed
1himan wants to merge 15 commits into
mne-tools:mainfrom
1himan:fix#13597
Closed

1himan wants to merge 15 commits into
mne-tools:mainfrom
1himan:fix#13597

Conversation

@1himan

@1himan 1himan commented Feb 20, 2026 •

Copy link
Copy Markdown
Contributor

Reference issue - Fixes #13597.

Fixes the type error:
image

which previously would've looked like:
image

@1himan

1himan commented Feb 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Okay I only see this now. There's already a typing utility in the repo. Would it be better if we add more elaborated types there? and import the type hints from there or mne.typing as suggested by @larsoner ?

Just say so and I'll start working it 😉.

@larsoner

Copy link
Copy Markdown
Member

There was at one point a lot of discussion of types and I don't offhand remember the outcomes. See for example #8218 (comment)

@1himan

1himan commented Feb 25, 2026 •

Copy link
Copy Markdown
Contributor Author

hey @scott-huberty for simplicity(only for right now), I've done this:
verbose: bool | str | int | None = None,

I see that you gave the notion about creatin a new typing module here - but there already exists one but there's nothing defined in there :)
What are your thoughts on this?

@1himan
1himan marked this pull request as draft February 28, 2026 07:19
@scott-huberty

Copy link
Copy Markdown
Contributor

hey @scott-huberty for simplicity(only for right now), I've done this: verbose: bool | str | int | None = None,

I see that you gave the notion about creatin a new typing module here - but there already exists one but there's nothing defined in there :) What are your thoughts on this?

I think that for type annotations to be useful they need to be correct, so that's why we suggested something like VerboseT: TypeAlias = None | bool | Literal["debug", "info", "warning", "error"] | int (note the use of Literal instead of just saying any str is valid, which it isn't). Also, by creating a type alias now, we save another dev the trouble in the future! (verbose parameters exist all over the mne codebase, so the chances that a dev will re-use our type hint are high).

As for whether to put this in mne.utils._typing or in a new module named mne.typing, I don't have a strong opinion. I guess it can be placed in the existing private module and we can always migrate things to a new public module later.

Also, it might be worth reading the thread that Eric linked above, to see what other ideas/opinions have been shared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Type hints for mne.preprocessing.ICA() are narrower than their runtime behavior and documented usage.

3 participants