Skip to content

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

Open

Description

@orikanner

Description of the problem

The runtime behavior and documentation allow a wider range of inputs than the current type annotations.

This causes false positives in static type checkers. Updating the type hints would align them with existing runtime behavior and documentation only, without modifying any runtime logic.

Steps to reproduce

from mne.preprocessing import ICA

ica = ICA(n_components=3, max_iter=1000)

Link to data

No response

Expected results

No type checker error, since the documentation specifies that max_iter accepts int | 'auto'.

Actual results

Static type checker reports:

Argument of type Literal[1000] cannot be assigned to parameter max_iter of type str

Additional information

This issue affects type checking only. Runtime behavior is correct.

I’d be happy to work on a fix for this if it’s confirmed as a bug.

Activity

  1. welcome commented on Jan 18, 2026

    @welcome

    Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴

  2. changed the title [-]Type hints for `mne.preprocessing.ICA()` and `mne.create_info()` are narrower than their runtime behavior and documented usage.[/-] [+]Type hints for `mne.preprocessing.ICA()` are narrower than their runtime behavior and documented usage.[/+] on Jan 19, 2026
  3. larsoner commented on Jan 19, 2026

    @larsoner
    Member

    @orikanner our type hinting is still quite immature, a PR to improve it would be welcome!

  4. orikanner commented on Jan 19, 2026

    @orikanner
    Author

    Thanks! I’ll work on this.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions