Skip to content

Commit

Permalink
mypy + fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
c-peters committed Oct 18, 2023
1 parent a17ba0d commit e95c5f0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 2 additions & 3 deletions py-polars/polars/datatypes/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,9 @@ def __repr__(self) -> str:
class Categorical(DataType):
"""A categorical encoding of a set of strings."""

categories: List[str] | None = None
categories: list[str] | None = None

def __init__(self, categories: List[str] | None = None):
def __init__(self, categories: list[str] | None = None):
"""
Categorical data type.
Expand All @@ -430,7 +430,6 @@ def __init__(self, categories: List[str] | None = None):
self.categories = categories



class Object(DataType):
"""Type for wrapping arbitrary Python objects."""

Expand Down
9 changes: 8 additions & 1 deletion py-polars/polars/utils/_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,14 @@ def sequence_to_pyseries(
pyseries = _construct_series_with_fallbacks(
constructor, name, values, dtype, strict=strict
)
if dtype in (Date, Datetime, Duration, Time, Boolean,Categorical) or isinstance(dtype,Categorical):
if dtype in (
Date,
Datetime,
Duration,
Time,
Boolean,
Categorical,
) or isinstance(dtype, Categorical):
if pyseries.dtype() != dtype:
pyseries = pyseries.cast(dtype, strict=True)
return pyseries
Expand Down

0 comments on commit e95c5f0

Please sign in to comment.