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

(🎁) Support Python 3.11 #398

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.8', '3.9', '3.10.6']
python-version: ['3.8', '3.9', '3.10.6', '3.11']

steps:
- uses: actions/checkout@v3
Expand Down
8 changes: 8 additions & 0 deletions pandas-stubs/core/arrays/arrow/dtype.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import sys
from typing import Any

import pyarrow as pa

from pandas.core.dtypes.base import StorageExtensionDtype

if sys.version_info < (3, 11):
import pyarrow as pa
else:
pa: Any

class ArrowDtype(StorageExtensionDtype):
pyarrow_dtype: pa.DataType
def __init__(self, pyarrow_dtype: pa.DataType) -> None: ...
10 changes: 6 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Scientific/Engineering"
]
packages = [
Expand All @@ -30,12 +31,13 @@ packages = [
"Documentation" = "https://pandas.pydata.org/pandas-docs/stable"

[tool.poetry.dependencies]
python = ">=3.8,<3.11"
python = ">=3.8,<3.12"
types-pytz = ">= 2022.1.1"

[tool.poetry.dev-dependencies]
mypy = "0.990"
pyarrow = ">=9.0.0"
# Until pyarrow releases wheels for 3.11 this is required to make the ci pass
pyarrow = { version = ">=9.0.0", python = "<3.11" }
pytest = ">=7.1.2"
pyright = ">=1.1.278"
poethepoet = "0.16.0"
Expand All @@ -47,8 +49,8 @@ pre-commit = ">=2.19.0"
black = ">=22.8.0"
isort = ">=5.10.1"
openpyxl = ">=3.0.10"
tables = ">=3.7.0"
lxml = ">=4.7.1,<4.9.0"
tables = { version = ">=3.7.0", python = "<3.11" }
lxml = { version = ">=4.7.1,<4.9.0", python = "<3.11" }
pyreadstat = ">=1.1.9"
xlrd = ">=2.0.1"
pyxlsb = ">=1.0.9"
Expand Down
4 changes: 3 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
AbstractContextManager,
nullcontext,
)
import functools
import os
import platform
from typing import (
Callable,
TYPE_CHECKING,
Final,
)
Expand All @@ -15,7 +17,7 @@
from pandas.util.version import Version
import pytest

from pandas._typing import T
from pandas._typing import T, F

TYPE_CHECKING_INVALID_USAGE: Final = TYPE_CHECKING
WINDOWS = os.name == "nt" or "cygwin" in platform.system().lower()
Expand Down
16 changes: 15 additions & 1 deletion tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pathlib
from pathlib import Path
import sqlite3
import sys
from typing import (
TYPE_CHECKING,
Any,
Expand Down Expand Up @@ -69,13 +70,21 @@
CWD = os.path.split(os.path.abspath(__file__))[0]


arrow_skip = pytest.mark.skipif(sys.version_info >= (3, 11), "pyarrow is not available for 3.11 yet")
"""This is only needed temporarily due to no wheels being available for arrow on 3.11"""

lxml_skip = pytest.mark.skipif(sys.version_info >= (3, 11), "pyarrow is not available for 3.11 yet")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong reason in the explanation here. Should be lxml not arrow.

"""This is only needed temporarily due to no wheels being available for arrow on 3.11"""

@arrow_skip
@pytest.mark.skipif(WINDOWS, reason="ORC not available on windows")
def test_orc():
with ensure_clean() as path:
check(assert_type(DF.to_orc(path), None), type(None))
check(assert_type(read_orc(path), DataFrame), DataFrame)


@arrow_skip
@pytest.mark.skipif(WINDOWS, reason="ORC not available on windows")
def test_orc_path():
with ensure_clean() as path:
Expand All @@ -84,6 +93,7 @@ def test_orc_path():
check(assert_type(read_orc(pathlib_path), DataFrame), DataFrame)


@arrow_skip
@pytest.mark.skipif(WINDOWS, reason="ORC not available on windows")
def test_orc_buffer():
with ensure_clean() as path:
Expand All @@ -96,18 +106,20 @@ def test_orc_buffer():
file_r.close()


@arrow_skip
@pytest.mark.skipif(WINDOWS, reason="ORC not available on windows")
def test_orc_columns():
with ensure_clean() as path:
check(assert_type(DF.to_orc(path, index=False), None), type(None))
check(assert_type(read_orc(path, columns=["a"]), DataFrame), DataFrame)


@arrow_skip
@pytest.mark.skipif(WINDOWS, reason="ORC not available on windows")
def test_orc_bytes():
check(assert_type(DF.to_orc(index=False), bytes), bytes)


@lxml_skip
def test_xml():
with ensure_clean() as path:
check(assert_type(DF.to_xml(path), None), type(None))
Expand All @@ -116,6 +128,7 @@ def test_xml():
check(assert_type(read_xml(f), DataFrame), DataFrame)


@lxml_skip
def test_xml_str():
with ensure_clean() as path:
check(assert_type(DF.to_xml(), str), str)
Expand Down Expand Up @@ -282,6 +295,7 @@ def test_sas_xport() -> None:
pass


@lxml_skip
def test_hdf():
with ensure_clean() as path:
check(assert_type(DF.to_hdf(path, "df"), None), type(None))
Expand Down
7 changes: 5 additions & 2 deletions tests/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@
from pandas._libs.tslibs import NaTType
from pandas._typing import Scalar


from tests import (
TYPE_CHECKING_INVALID_USAGE,
check,
importskip
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this import is failing.

)

pyarrow_skip = pytest.mark.skip
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be

pyarrow_skip = pytest.mark.skipif(sys.version_info >= (3, 11), "pyarrow is not available for 3.11 yet")
"""This is only needed temporarily due to no wheels being available for arrow on 3.11"""

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appears to be not needed.



def test_types_to_datetime() -> None:
df = pd.DataFrame({"year": [2015, 2016], "month": [2, 3], "day": [4, 5]})
Expand Down Expand Up @@ -461,9 +465,8 @@ def test_crosstab() -> None:
)


@pyarrow_skip
def test_arrow_dtype() -> None:
pytest.importorskip("pyarrow")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These is there for a reason to protect Windows. I think it should stay.


import pyarrow as pa

check(
Expand Down