Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Static type checkers can't recognize colormaps

Open
#120 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python

Research direction

Inspect cmocean/cm.py and the cmap_d definition to see how colormaps are created dynamically. Compare the referenced Matplotlib cm.pyi stub and determine how a generated stub would expose the colormap attributes and types; done means MyPy and Pylance recognize entries such as cmocean.cm.balance.

Written by the indexing model from the issue text.

Description

Static type checkers like MyPy or Pylance can't recognize variables created dynamically with locals().update(cmap_d). Past just type checking, Pylance can't even recognize that colormaps exist, e.g., cmocean.cm.balance produces an attribute access issue error in Pylance.

Matplotlib colormaps have the same issue, which they solve by including a stub file cm.pyi that defines the attributes and types.

If there's interest in include a cm.pyi file here, it is straightforward to generate one automatically based on the colormaps defined in cmap_d and I'd be happy to make a PR with the details.

Dominant language
Python
Stars
269
Forks
54
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from matplotlib/cmocean

All issues in matplotlib/cmocean

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.