Static type checkers can't recognize colormaps
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
- Domain
- data-visualization
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from matplotlib/cmocean
-
Difficulty 2/5 1-3 hours Newbie friendliness 50/100
matplotlib/cmocean#119 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 52/100
matplotlib/cmocean#118 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
matplotlib/cmocean#116 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
matplotlib/cmocean#115 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
matplotlib/cmocean#112 ·
All issues in matplotlib/cmocean
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
canonical/paas-charm#368 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
tech debt
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
StevenBlack/hosts#3256 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
qualcomm/qai-appbuilder#275 ·