Skip to content

[MNT] [TYPING]: Update MarkerType (#30257) #30261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/matplotlib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
The ``typing`` module and type stub files are considered provisional and may change
at any time without a deprecation period.
"""
from builtins import list
from collections.abc import Hashable, Sequence
import pathlib
from typing import Any, Callable, Literal, TypeAlias, TypeVar, Union
Expand Down Expand Up @@ -69,7 +70,16 @@
)
"""See :doc:`/gallery/lines_bars_and_markers/markevery_demo`."""

MarkerType: TypeAlias = str | path.Path | MarkerStyle
MarkerType: TypeAlias = (
path.Path | MarkerStyle | str | # str required for "$...$" marker
Literal[
Copy link
Member

@timhoffm timhoffm Jul 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have to keep str anyway, what is the advantage of spelling out the literal string values?

we can’t detect invalid values and completion also is not a relevant benefit if the values are almost all single characters.

Copy link
Contributor Author

@ZPyrolink ZPyrolink Jul 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that we don't really get completion, but we don't lose the suggestion when the string is opened.
That said, if you prefer, I can remove this and only keep the integers.

".", ",", "o", "v", "^", "<", ">",
"1", "2", "3", "4", "8", "s", "p",
"P", "*", "h", "H", "+", "x", "X",
"D", "d", "|", "_", "none", " ",
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
] | list[tuple[int, int]] | tuple[int, Literal[1, 2, 3], int]
)
"""
Marker specification. See :doc:`/gallery/lines_bars_and_markers/marker_reference`.
"""
Expand Down
Loading