Skip to content

Commit

Permalink
Remove duplicate binary import warnings (#1036)
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego authored and ritchie46 committed Jul 25, 2021
1 parent 009a46f commit 953f3cd
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 91 deletions.
14 changes: 6 additions & 8 deletions py-polars/polars/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# flake8: noqa
try:
from polars.polars import version
except ImportError as e:
raise ImportError("Polars binary files missing!") from e

# mypy needs these imported explicitly
from polars.eager.frame import DataFrame, wrap_df
Expand All @@ -15,14 +19,6 @@
from .lazy import *
from .string_cache import *

# during docs building the binary code is not yet available
try:
from .polars import version

__version__ = version()
except ImportError:
pass

__all__ = (
convert.__all__
+ datatypes.__all__
Expand All @@ -32,3 +28,5 @@
+ lazy.__all__
+ string_cache.__all__
)

__version__ = version()
14 changes: 1 addition & 13 deletions py-polars/polars/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,7 @@
import pyarrow as pa
from _ctypes import _SimpleCData

try:
from polars.polars import PySeries
except ImportError:
import warnings

warnings.warn("binary files missing")

__pdoc__ = {
"dtype_to_ctype": False,
"dtype_to_int": False,
"dtype_to_primitive": False,
"pytype_to_polars_type": False,
}
from polars.polars import PySeries

__all__ = [
"DataType",
Expand Down
6 changes: 1 addition & 5 deletions py-polars/polars/eager/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,12 @@
sequence_to_pydf,
series_to_pydf,
)
from polars.polars import PyDataFrame, PySeries

from .._html import NotebookFormatter
from ..datatypes import DTYPES, Boolean, DataType, UInt32, pytype_to_polars_type
from ..utils import _process_null_values

try:
from ..polars import PyDataFrame, PySeries
except ImportError:
warnings.warn("binary files missing")

try:
import pandas as pd

Expand Down
15 changes: 1 addition & 14 deletions py-polars/polars/eager/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
sequence_to_pyseries,
series_to_pyseries,
)
from polars.polars import PyDataFrame, PySeries

from ..datatypes import (
DTYPE_TO_FFINAME,
Expand All @@ -39,20 +40,6 @@
)
from ..utils import _ptr_to_numpy

try:
from ..polars import PyDataFrame, PySeries
except ImportError:
import warnings

warnings.warn("binary files missing")
__pdoc__ = {
"wrap_s": False,
"find_first_non_none": False,
"out_to_dtype": False,
"get_ffi_func": False,
"SeriesIter": False,
}

__all__ = [
"Series",
]
Expand Down
6 changes: 1 addition & 5 deletions py-polars/polars/internals/construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@
py_type_to_arrow_type,
py_type_to_constructor,
)
from polars.polars import PyDataFrame, PySeries
from polars.utils import coerce_arrow

try:
from polars.polars import PyDataFrame, PySeries
except ImportError:
warnings.warn("binary files missing")

if TYPE_CHECKING:
import pandas as pd

Expand Down
9 changes: 1 addition & 8 deletions py-polars/polars/lazy/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,11 @@
from typing import Any, Callable, Optional, Sequence, Type, Union

import polars as pl
from polars.polars import PyExpr

from ..datatypes import Boolean, DataType, Date32, Date64, Float64, Int64, Utf8
from .functions import UDF, col, lit

try:
from ..polars import PyExpr
except ImportError:
import warnings

warnings.warn("Binary files missing.")
__pdoc__ = {"wrap_expr": False}

__all__ = [
"Expr",
"ExprStringNameSpace",
Expand Down
9 changes: 1 addition & 8 deletions py-polars/polars/lazy/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,12 @@
from typing import Any, Callable, Dict, Optional, Sequence, Tuple, Type, Union

import polars as pl
from polars.polars import PyExpr, PyLazyFrame, PyLazyGroupBy

from ..datatypes import DataType, pytype_to_polars_type
from ..utils import _process_null_values
from .expr import UDF, Expr, _selection_to_pyexpr_list, col, expr_to_lit_or_expr, lit

try:
from ..polars import PyExpr, PyLazyFrame, PyLazyGroupBy
except ImportError:
import warnings

warnings.warn("Binary files missing.")
__pdoc__ = {"wrap_ldf": False}

__all__ = [
"LazyFrame",
]
Expand Down
26 changes: 10 additions & 16 deletions py-polars/polars/lazy/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,19 @@
import numpy as np

import polars as pl
from polars.polars import argsort_by as pyargsort_by
from polars.polars import binary_function as pybinary_function
from polars.polars import col as pycol
from polars.polars import concat_str as _concat_str
from polars.polars import cov as pycov
from polars.polars import except_ as pyexcept
from polars.polars import fold as pyfold
from polars.polars import lit as pylit
from polars.polars import pearson_corr as pypearson_corr
from polars.polars import series_from_range as _series_from_range

from ..datatypes import DataType, Date64, Int64

try:
from ..polars import argsort_by as pyargsort_by
from ..polars import binary_function as pybinary_function
from ..polars import col as pycol
from ..polars import concat_str as _concat_str
from ..polars import cov as pycov
from ..polars import except_ as pyexcept
from ..polars import fold as pyfold
from ..polars import lit as pylit
from ..polars import pearson_corr as pypearson_corr
from ..polars import series_from_range as _series_from_range
except ImportError:
import warnings

warnings.warn("Binary files missing.")

__all__ = [
"col",
"except_",
Expand Down
8 changes: 1 addition & 7 deletions py-polars/polars/lazy/whenthen.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
from typing import Any, Union

import polars as pl
from polars.polars import when as pywhen

from .expr import expr_to_lit_or_expr

try:
from ..polars import when as pywhen
except ImportError:
import warnings

warnings.warn("Binary files missing.")

__all__ = ["when"]


Expand Down
8 changes: 1 addition & 7 deletions py-polars/polars/string_cache.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
from types import TracebackType
from typing import Optional, Type

try:
from .polars import toggle_string_cache as pytoggle_string_cache
except ImportError:
import warnings

warnings.warn("binary files missing")

from polars.polars import toggle_string_cache as pytoggle_string_cache

__all__ = [
"StringCache",
Expand Down

0 comments on commit 953f3cd

Please sign in to comment.