Skip to content

Commit

Permalink
chore(python): Fix SIM105 issues. (#6042)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghuls committed Jan 4, 2023
1 parent 5408108 commit 4bd67da
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
4 changes: 1 addition & 3 deletions py-polars/polars/internals/construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,9 @@ def sequence_to_pyseries(
)
except ValueError: # pragma: no cover
return sequence_from_anyvalue_or_object(name, values)
try:
with suppress(pa.lib.ArrowInvalid, pa.lib.ArrowTypeError):
arrow_values = pa.array(values, pa.large_list(nested_arrow_dtype))
return arrow_to_pyseries(name, arrow_values)
except (pa.lib.ArrowInvalid, pa.lib.ArrowTypeError):
pass

# Convert mixed sequences like `[[12], "foo", 9]`
return PySeries.new_object(name, values, strict)
Expand Down
6 changes: 2 additions & 4 deletions py-polars/polars/internals/io.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import glob
from contextlib import contextmanager
from contextlib import contextmanager, suppress
from io import BytesIO, StringIO
from pathlib import Path
from typing import Any, BinaryIO, ContextManager, Iterator, TextIO, overload
Expand All @@ -11,11 +11,9 @@
from polars.dependencies import _FSSPEC_AVAILABLE, fsspec
from polars.utils import format_path

try:
with suppress(ImportError):
from polars.polars import ipc_schema as _ipc_schema
from polars.polars import parquet_schema as _parquet_schema
except ImportError:
pass


def _process_http_file(path: str, encoding: str | None = None) -> BytesIO:
Expand Down
6 changes: 2 additions & 4 deletions py-polars/tests/unit/io/test_sql_db.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import os
from contextlib import suppress
from datetime import date

import polars as pl
Expand All @@ -10,7 +11,7 @@ def test_read_sql() -> None:
import sqlite3
import tempfile

try:
with suppress(ImportError):
import connectorx # noqa: F401

with tempfile.TemporaryDirectory() as tmpdir_name:
Expand Down Expand Up @@ -52,6 +53,3 @@ def test_read_sql() -> None:
assert df.shape == (2, 4)
assert df["date"].to_list() == [date(2020, 1, 1), date(2021, 12, 31)]
# assert df.rows() == ...

except ImportError:
pass # if connectorx not installed on test machine

0 comments on commit 4bd67da

Please sign in to comment.