Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(python)!: drop Python 3.7 support #9679

Merged
merged 7 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/lint-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.11']
python-version: ['3.8', '3.11']
defaults:
run:
working-directory: py-polars
Expand All @@ -59,4 +59,4 @@ jobs:
# Allow untyped calls for older Python versions
- name: Run mypy
run: mypy ${{ (matrix.python-version == '3.7') && '--allow-untyped-calls' || '' }}
run: mypy ${{ (matrix.python-version == '3.8') && '--allow-untyped-calls' || '' }}
2 changes: 1 addition & 1 deletion .github/workflows/release-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

env:
RUST_TOOLCHAIN: nightly-2023-06-23
PYTHON_VERSION: '3.7'
PYTHON_VERSION: '3.8'
MATURIN_VERSION: '1.1.0'
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.11']
python-version: ['3.8', '3.11']

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion py-polars/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ once_cell = "1"
polars-algo = { path = "../polars/polars-algo", default-features = false }
polars-core = { path = "../polars/polars-core", features = ["python"], default-features = false }
polars-lazy = { path = "../polars/polars-lazy", features = ["python"], default-features = false }
pyo3 = { version = "0.19", features = ["abi3-py37", "extension-module", "multiple-pymethods"] }
pyo3 = { version = "0.19", features = ["abi3-py38", "extension-module", "multiple-pymethods"] }
pyo3-built = { version = "0.4", optional = true }
serde_json = { version = "1", optional = true }
smartstring = "1"
Expand Down
7 changes: 1 addition & 6 deletions py-polars/polars/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,11 @@ def _get_float_fmt() -> str:
from polars.polars import set_float_fmt as _set_float_fmt

if TYPE_CHECKING:
import sys
from types import TracebackType
from typing import Literal

from polars.type_aliases import FloatFmt

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal


# note: register all Config-specific environment variable names here; need to constrain
# which 'POLARS_' environment variables are recognised, as there are other lower-level
Expand Down
4 changes: 2 additions & 2 deletions py-polars/polars/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ def from_pandas(

@overload
def from_pandas(
data: pd.Series | pd.DatetimeIndex,
data: pd.Series[Any] | pd.Index,
*,
schema_overrides: SchemaDict | None = ...,
rechunk: bool = ...,
Expand All @@ -650,7 +650,7 @@ def from_pandas(


def from_pandas(
data: pd.DataFrame | pd.Series | pd.DatetimeIndex,
data: pd.DataFrame | pd.Series[Any] | pd.Index,
*,
schema_overrides: SchemaDict | None = None,
rechunk: bool = True,
Expand Down
6 changes: 1 addition & 5 deletions py-polars/polars/dataframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
import sys
from datetime import timedelta
from io import IOBase
from typing import Literal

import deltalake
from pyarrow.interchange.dataframe import _PyArrowDataFrame
Expand Down Expand Up @@ -154,11 +155,6 @@
)
from polars.utils import NoDefault

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal

if sys.version_info >= (3, 10):
from typing import Concatenate, ParamSpec, TypeAlias
else:
Expand Down
16 changes: 3 additions & 13 deletions py-polars/polars/datatypes/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
Optional,
TypeVar,
Union,
get_args,
overload,
)

Expand Down Expand Up @@ -54,14 +55,6 @@
with contextlib.suppress(ImportError): # Module not available when building docs
from polars.polars import dtype_str_repr as _dtype_str_repr

if sys.version_info >= (3, 8):
from typing import get_args
else:
# pass-through (only impact is that under 3.7 we'll end-up doing
# standard inference for dataclass fields with an option/union)
def get_args(tp: Any) -> Any:
return tp


OptionType = type(Optional[type])
if sys.version_info >= (3, 10):
Expand All @@ -72,12 +65,9 @@ def get_args(tp: Any) -> Any:
UnionType = type(Union[int, float])

if TYPE_CHECKING:
from polars.type_aliases import PolarsDataType, PythonDataType, SchemaDict, TimeUnit
from typing import Literal

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
from polars.type_aliases import PolarsDataType, PythonDataType, SchemaDict, TimeUnit


T = TypeVar("T")
Expand Down
7 changes: 1 addition & 6 deletions py-polars/polars/functions/as_datatype.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,11 @@


if TYPE_CHECKING:
import sys
from typing import Literal

from polars import Expr, Series
from polars.type_aliases import IntoExpr, SchemaDict

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal


def datetime_(
year: Expr | str | int,
Expand Down
13 changes: 1 addition & 12 deletions py-polars/polars/functions/eager.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,8 @@
import polars.polars as plr

if TYPE_CHECKING:
import sys

from polars import DataFrame, Expr, LazyFrame, Series
from polars.type_aliases import (
ConcatMethod,
JoinStrategy,
PolarsType,
)

if sys.version_info >= (3, 8):
pass
else:
pass
from polars.type_aliases import ConcatMethod, JoinStrategy, PolarsType


def concat(
Expand Down
7 changes: 1 addition & 6 deletions py-polars/polars/functions/lazy.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@


if TYPE_CHECKING:
import sys
from typing import Literal

from polars import DataFrame, Expr, LazyFrame, Series
from polars.type_aliases import (
Expand All @@ -47,11 +47,6 @@
TimeUnit,
)

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal


def col(
name: str | PolarsDataType | Iterable[str] | Iterable[PolarsDataType],
Expand Down
7 changes: 1 addition & 6 deletions py-polars/polars/functions/range.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,12 @@
import polars.polars as plr

if TYPE_CHECKING:
import sys
from datetime import date
from typing import Literal

from polars import Expr, Series
from polars.type_aliases import ClosedInterval, PolarsDataType, TimeUnit

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal


@overload
def arange(
Expand Down
7 changes: 1 addition & 6 deletions py-polars/polars/functions/repeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


if TYPE_CHECKING:
import sys
from typing import Literal

from polars import Expr, Series
from polars.type_aliases import (
Expand All @@ -24,11 +24,6 @@
PolarsExprType,
)

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal


@overload
def repeat(
Expand Down
7 changes: 1 addition & 6 deletions py-polars/polars/io/excel/_write_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from polars.exceptions import DuplicateError

if TYPE_CHECKING:
import sys
from typing import Literal

from xlsxwriter import Workbook
from xlsxwriter.format import Format
Expand All @@ -36,11 +36,6 @@
RowTotalsDefinition,
)

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal


def _cluster(iterable: Iterable[Any], n: int = 2) -> Iterable[Any]:
return zip(*[iter(iterable)] * n)
Expand Down
7 changes: 1 addition & 6 deletions py-polars/polars/io/excel/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,11 @@
from polars.utils.various import normalise_filepath

if TYPE_CHECKING:
import sys
from io import BytesIO
from typing import Literal

from polars import DataFrame

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal


@overload
def read_excel(
Expand Down
6 changes: 1 addition & 5 deletions py-polars/polars/lazyframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
if TYPE_CHECKING:
import sys
from io import IOBase
from typing import Literal

import pyarrow as pa

Expand All @@ -94,11 +95,6 @@
UniqueKeepStrategy,
)

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal

if sys.version_info >= (3, 10):
from typing import Concatenate, ParamSpec
else:
Expand Down
4 changes: 2 additions & 2 deletions py-polars/polars/series/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def _from_arrow(cls, name: str, values: pa.Array, *, rechunk: bool = True) -> Se
def _from_pandas(
cls,
name: str,
values: pd.Series | pd.DatetimeIndex,
values: pd.Series[Any] | pd.DatetimeIndex,
*,
nan_to_null: bool = True,
) -> Self:
Expand Down Expand Up @@ -3421,7 +3421,7 @@ def to_arrow(self) -> pa.Array:

def to_pandas( # noqa: D417
self, *args: Any, use_pyarrow_extension_array: bool = False, **kwargs: Any
) -> pd.Series:
) -> pd.Series[Any]:
"""
Convert this Series to a pandas Series.
Expand Down
6 changes: 1 addition & 5 deletions py-polars/polars/sql/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@
if TYPE_CHECKING:
import sys
from types import TracebackType

if sys.version_info >= (3, 8):
from typing import Final, Literal
else:
from typing_extensions import Final, Literal
from typing import Final, Literal

if sys.version_info >= (3, 11):
from typing import Self
Expand Down
7 changes: 1 addition & 6 deletions py-polars/polars/testing/parametric/primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,13 @@
)

if TYPE_CHECKING:
import sys
from typing import Literal

from hypothesis.strategies import DrawFn, SearchStrategy

from polars import LazyFrame
from polars.type_aliases import OneOrMoreDataTypes, PolarsDataType

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal


_time_units = list(DTYPE_TEMPORAL_UNITS)

Expand Down
3 changes: 1 addition & 2 deletions py-polars/polars/testing/parametric/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import os
import re
import sys

from hypothesis import settings

Expand Down Expand Up @@ -91,7 +90,7 @@ def set_profile(profile: ParametricProfileNames | int) -> None:
if profile_name.replace("_", "").isdigit():
profile_name = str(int(profile_name))

elif sys.version_info >= (3, 8):
else:
from typing import get_args

valid_profile_names = get_args(ParametricProfileNames)
Expand Down
9 changes: 3 additions & 6 deletions py-polars/polars/type_aliases.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import sys
from datetime import date, datetime, time, timedelta
from decimal import Decimal
from typing import (
Expand All @@ -9,6 +8,7 @@
Collection,
Iterable,
List,
Literal,
Mapping,
Sequence,
Tuple,
Expand All @@ -17,12 +17,9 @@
Union,
)

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal

if TYPE_CHECKING:
import sys

from polars import DataFrame, Expr, LazyFrame, Series
from polars.datatypes import DataType, DataTypeClass, TemporalType
from polars.dependencies import numpy as np
Expand Down
Loading