|
11 | 11 | from tempfile import TemporaryDirectory
|
12 | 12 | from typing import IO, Any, Literal, Optional, Self, Type
|
13 | 13 |
|
| 14 | +import matplotlib as mpl |
14 | 15 | import numpy as np
|
15 | 16 | from matplotlib import get_cachedir
|
16 | 17 | from matplotlib.backend_bases import (
|
|
22 | 23 | from matplotlib.path import Path
|
23 | 24 | from matplotlib.text import Text
|
24 | 25 | from matplotlib.transforms import Affine2DBase, Transform
|
25 |
| -from matplotlib.typing import ColorType |
26 | 26 | from numpy.typing import ArrayLike
|
27 | 27 | from PIL import Image, ImageOps
|
28 | 28 |
|
| 29 | +# Module `matplotlib.typing` has been introduced in matplotlib@3.8 but the |
| 30 | +# latest Ubuntu LTS 24.04 provides matplotlib@3.6. Since we are not ready to |
| 31 | +# abandont typing hints and support of the most popular distros is desirable, |
| 32 | +# we keep this version check until Ubuntu LTS 26.04. |
| 33 | +# |
| 34 | +# https://github.com/daskol/mpl-typst/issues/24 |
| 35 | +if mpl.__version_info__ >= (3, 8): |
| 36 | + from matplotlib.typing import ColorType |
| 37 | +else: |
| 38 | + ColorType = Any |
| 39 | + |
29 | 40 | from mpl_typst.config import Config, compiler
|
30 | 41 | from mpl_typst.typst import (
|
31 | 42 | Array, Block, Call, Content, Dictionary, Scalar, Writer as TypstWriter)
|
|
0 commit comments