Skip to content

Static type checkers can't recognize colormaps #120

Description

@andrew-s28

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions