Skip to content

Commit

Permalink
fix some test lint
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-beedie committed Oct 22, 2024
1 parent 8832963 commit ea52dce
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
18 changes: 12 additions & 6 deletions py-polars/polars/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,25 @@

from collections import OrderedDict
from collections.abc import Mapping
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Union

from polars.datatypes import DataType, is_polars_dtype
from polars._typing import PythonDataType
from polars.datatypes import DataType, DataTypeClass, is_polars_dtype
from polars.datatypes._parse import parse_into_dtype

if TYPE_CHECKING:
import sys
from collections.abc import Iterable

from polars._typing import PythonDataType
from polars.datatypes import DataTypeClass
if sys.version_info >= (3, 10):
from typing import TypeAlias
else:
from typing_extensions import TypeAlias


BaseSchema = OrderedDict[str, DataType]
SchemaInitDataType: TypeAlias = Union[DataType, DataTypeClass, PythonDataType]


__all__ = ["Schema"]

Expand Down Expand Up @@ -65,8 +71,8 @@ class Schema(BaseSchema):
def __init__(
self,
schema: (
Mapping[str, DataType | DataTypeClass | PythonDataType]
| Iterable[tuple[str, DataType | DataTypeClass | PythonDataType]]
Mapping[str, SchemaInitDataType]
| Iterable[tuple[str, SchemaInitDataType]]
| None
) = None,
*,
Expand Down
2 changes: 1 addition & 1 deletion py-polars/tests/unit/dataframe/test_df.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ def test_to_dummies() -> None:
"i": [1, 2, 3],
"category": ["dog", "cat", "cat"],
},
schema={"i": pl.Int32, "category": pl.Categorical},
schema={"i": pl.Int32, "category": pl.Categorical("lexical")},
)
expected = pl.DataFrame(
{
Expand Down
8 changes: 4 additions & 4 deletions py-polars/tests/unit/io/test_spreadsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,11 @@ def test_read_mixed_dtype_columns(
) -> None:
spreadsheet_path = request.getfixturevalue(source)
schema_overrides = {
"Employee ID": pl.Utf8,
"Employee Name": pl.Utf8,
"Date": pl.Date,
"Employee ID": pl.Utf8(),
"Employee Name": pl.Utf8(),
"Date": pl.Date(),
"Details": pl.Categorical("lexical"),
"Asset ID": pl.Utf8,
"Asset ID": pl.Utf8(),
}
df = read_spreadsheet(
spreadsheet_path,
Expand Down

0 comments on commit ea52dce

Please sign in to comment.