Skip to content

Adding ArrayLike from numpy as a type hint leads to doc build errors. #13840

@1himan

Description

@1himan

Description of the problem

I'm trying to improve type hints in the /home/himan/projects/mne-python-issue13597/mne/preprocessing/ica.py file with something like this(one of the functions in that file):

  def get_explained_variance_ratio(
      self,
      inst: BaseRaw | BaseEpochs | Evoked,
      *,
      components: ArrayLike | int | None = None,
      ch_type: Literal["mag", "grad", "planar1", "planar2", "eeg"]
      | ArrayLike
      | None = None,
  ):

however the ArrayLike - sphinx is unable to resolve this ref properly. And give the following error:

 <unknown>:1: WARNING: py:class reference target not found:
  numpy._typing.ArrayLike [ref.class]

Link to data

No response

Expected results

Should build docs without the error described above and add proper ref to the ArrayLike.

Actual results

Throws an error and fails to resolve link.

Additional information

Discussion on this.

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