I see the type hints from VS Code but I don't understand where they are defined in the code in Github

Hi everyone, sorry for the dumb question, if I move the mouse over ListedColormap from VS Code I see that “colors” has as type ArrayLike | Sequence[_ColorLike], but I can’t understand where it is defined in the matplotlib code in GitHub, can you help me?

Those hints are provided by vscode not by us.

1 Like

Oh wow, I didn’t know VS Code started doing that, thanks for the answer!

The source of those hints is:

GitHub - microsoft/python-type-stubs: A set of type stubs for popular Python packages. These are works in progress from the Microsoft Python team and others, with the intent that they are contributed to typeshed or to the associated packages once sufficiently complete.

1 Like

Ooh great thanks! I will check there then, very useful

Speaking of: I am working to improve those stubs, and Michael Droettboom told me that there is interest in a community maintained set of stubs. This is what we did with Pandas; I maintained stubs for a while in the Microsoft repo and recently handed them off to the Pandas team. The stubs we have now were hand-written by Jake Bailey; I am using monkeytype on the samples, pyright return type inference, and some hand tuning to make the new set. I would very much prefer to be able to hand these off if there is an interest once they are done (which should be sometime this month).

1 Like