Skip to content

Commit

Permalink
TYP: Fix new typing failures
Browse files Browse the repository at this point in the history
  • Loading branch information
has2k1 committed Apr 26, 2024
1 parent 76aa27d commit 6b35483
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion plotnine/_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def identity(*args: Any) -> Any:
"""
Return whatever is passed in
"""
return args if len(args) > 1 else args[0]
return args[0] if len(args) == 1 else args


def match(
Expand Down
4 changes: 2 additions & 2 deletions plotnine/coords/coord_trans.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ def get_scale_view(
trans,
# TODO: fix typecheck
sv.breaks, # type: ignore
sv.range, # type: ignore
sv.range,
)
sv.minor_breaks = transform_value(
trans,
sv.minor_breaks,
sv.range, # type: ignore
sv.range,
)
return sv

Expand Down
6 changes: 4 additions & 2 deletions plotnine/mapping/aes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class ColorOrColour(Protocol):
colour: Any

THasAesNames = TypeVar(
"THasAesNames", bound=Sequence[str] | dict[str, Any] | ColorOrColour
"THasAesNames",
bound=Sequence[str] | dict[str, Any] | ColorOrColour,
)

__all__ = ("aes",)
Expand Down Expand Up @@ -347,7 +348,8 @@ def rename_aesthetics(obj: THasAesNames) -> THasAesNames:
if name != new_name:
obj[new_name] = obj.pop(name)
elif isinstance(obj, Sequence):
return type(obj)(s.replace("colour", "color") for s in obj)
T = type(obj)
return T(s.replace("colour", "color") for s in obj) # pyright: ignore
elif obj.color is None and obj.colour is not None:
obj.color, obj.colour = obj.colour, None

Expand Down

0 comments on commit 6b35483

Please sign in to comment.