Skip to content

Commit 6b35483

Browse files
committed
TYP: Fix new typing failures
1 parent 76aa27d commit 6b35483

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

Diff for: plotnine/_utils/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def identity(*args: Any) -> Any:
8181
"""
8282
Return whatever is passed in
8383
"""
84-
return args if len(args) > 1 else args[0]
84+
return args[0] if len(args) == 1 else args
8585

8686

8787
def match(

Diff for: plotnine/coords/coord_trans.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@ def get_scale_view(
120120
trans,
121121
# TODO: fix typecheck
122122
sv.breaks, # type: ignore
123-
sv.range, # type: ignore
123+
sv.range,
124124
)
125125
sv.minor_breaks = transform_value(
126126
trans,
127127
sv.minor_breaks,
128-
sv.range, # type: ignore
128+
sv.range,
129129
)
130130
return sv
131131

Diff for: plotnine/mapping/aes.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ class ColorOrColour(Protocol):
2121
colour: Any
2222

2323
THasAesNames = TypeVar(
24-
"THasAesNames", bound=Sequence[str] | dict[str, Any] | ColorOrColour
24+
"THasAesNames",
25+
bound=Sequence[str] | dict[str, Any] | ColorOrColour,
2526
)
2627

2728
__all__ = ("aes",)
@@ -347,7 +348,8 @@ def rename_aesthetics(obj: THasAesNames) -> THasAesNames:
347348
if name != new_name:
348349
obj[new_name] = obj.pop(name)
349350
elif isinstance(obj, Sequence):
350-
return type(obj)(s.replace("colour", "color") for s in obj)
351+
T = type(obj)
352+
return T(s.replace("colour", "color") for s in obj) # pyright: ignore
351353
elif obj.color is None and obj.colour is not None:
352354
obj.color, obj.colour = obj.colour, None
353355

0 commit comments

Comments
 (0)