Skip to content

[pre-commit.ci] pre-commit autoupdate #230

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

Merged
merged 2 commits into from
Aug 5, 2025
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ repos:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.16.0
rev: v1.17.1
hooks:
- id: mypy
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.13
rev: v0.12.7
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
Expand Down
33 changes: 20 additions & 13 deletions labellines/core.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from __future__ import annotations

from typing import TYPE_CHECKING

import warnings
from typing import Optional, Union
from datetime import timedelta
import matplotlib.pyplot as plt
import numpy as np
Expand All @@ -17,21 +20,24 @@
from .line_label import LineLabel
from .utils import maximum_bipartite_matching, normalize_xydata

if TYPE_CHECKING:
from line_label import Position


# Label line with line2D label data
def labelLine(
line: Line2D,
x,
label: Optional[str] = None,
align: Optional[bool] = None,
x: Position,
label: str | None = None,
align: bool | None = None,
drop_label: bool = False,
xoffset: float = 0,
xoffset_logspace: bool = False,
yoffset: float = 0,
yoffset_logspace: bool = False,
outline_color: str = "auto",
outline_width: float = 8,
rotation: Optional[float] = None,
rotation: float | None = None,
**kwargs,
):
"""
Expand Down Expand Up @@ -107,16 +113,16 @@ def labelLine(


def labelLines(
lines: Optional[list[Line2D]] = None,
align: Optional[bool] = None,
xvals: Optional[Union[tuple[float, float], list[float]]] = None,
lines: list[Line2D] | None = None,
align: bool | None = None,
xvals: tuple[Position, Position] | list[Position] | None = None,
drop_label: bool = False,
shrink_factor: float = 0.05,
xoffsets: Union[float, list[float]] = 0,
yoffsets: Union[float, list[float]] = 0,
xoffsets: float | list[float] = 0,
yoffsets: float | list[float] = 0,
outline_color: str = "auto",
outline_width: float = 5,
rotation: Optional[bool] = None,
rotation: bool | None = None,
**kwargs,
):
"""Label all lines with their respective legends.
Expand Down Expand Up @@ -266,8 +272,9 @@ def labelLines(
if not (xmin <= xv <= xmax):
warnings.warn(
(
f"The value at position {i} in `xvals` is outside the range of its "
f"associated line ({xmin=}, {xmax=}, xval={xv}). "
f"The value at position {i} in `xvals` is outside the "
"range of its associated line "
f"({xmin=}, {xmax=}, xval={xv}). "
"Clipping it into the allowed range."
),
UserWarning,
Expand Down
10 changes: 5 additions & 5 deletions labellines/line_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

if TYPE_CHECKING:
from datetime import datetime
from typing import Any, Literal, Optional, Union
from typing import Any, Literal, Union

from matplotlib.axes import Axes
from matplotlib.lines import Line2D
Expand Down Expand Up @@ -62,15 +62,15 @@ def __init__(
self,
line: Line2D,
x: Position,
label: Optional[str] = None,
align: Optional[bool] = None,
label: str | None = None,
align: bool | None = None,
xoffset: float = 0,
xoffset_logspace: bool = False,
yoffset: float = 0,
yoffset_logspace: bool = False,
outline_color: Optional[Union[AutoLiteral, ColorLike]] = "auto",
outline_color: AutoLiteral | ColorLike | None = "auto",
outline_width: float = 8,
rotation: Optional[float] = None,
rotation: float | None = None,
**kwargs,
) -> None:
"""
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ filterwarnings = [
]

[tool.ruff.lint]
ignore = ["N802", "N806", "C901", "UP007"]
ignore = ["N802", "N806", "C901"]
select = ["E", "C", "F", "UP", "B", "A", "YTT", "S", "N"]


Expand Down