Skip to content

CI: start testing Python 3.11 #47442

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

Merged
merged 41 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
5fbeaeb
CI: start testing Python 3.11
fangchenli Jun 21, 2022
4805a6b
fix
fangchenli Jun 21, 2022
9f038f3
fix
fangchenli Jun 21, 2022
532ce7d
Merge remote-tracking branch 'upstream/main' into test-py311
fangchenli Jun 22, 2022
2b45e32
fix macos
fangchenli Jun 22, 2022
bfbd17b
add error msg compat
fangchenli Jun 22, 2022
bac8cbd
fix error msg in test
fangchenli Jun 23, 2022
f9bd7de
Merge remote-tracking branch 'upstream/main' into test-py311
fangchenli Jun 23, 2022
df998dc
Merge remote-tracking branch 'upstream/main' into test-py311
fangchenli Jun 24, 2022
572acef
xfail and skip tests
fangchenli Jun 24, 2022
c5f2fe3
fix error
fangchenli Jun 25, 2022
69ea5ed
roll back
fangchenli Jun 25, 2022
a244f85
Merge remote-tracking branch 'upstream/main' into test-py311
fangchenli Jun 25, 2022
981c5a9
Merge remote-tracking branch 'upstream/main' into test-py311
fangchenli Jun 30, 2022
110459a
Merge remote-tracking branch 'upstream/main' into test-py311
fangchenli Jul 2, 2022
267c9f2
revert
fangchenli Jul 2, 2022
b6e0e22
Merge remote-tracking branch 'upstream/main' into test-py311
fangchenli Jul 5, 2022
6979eb1
Merge remote-tracking branch 'upstream/main' into test-py311
fangchenli Jul 13, 2022
097e98b
Merge branch 'main' into test-py311
lithomas1 Aug 2, 2022
32f3430
Merge remote-tracking branch 'upstream/main' into test-py311
fangchenli Aug 3, 2022
f832e00
Merge remote-tracking branch 'origin/test-py311' into test-py311
fangchenli Aug 3, 2022
77dab8a
maybe fix errors
lithomas1 Aug 6, 2022
bc1a776
update
lithomas1 Aug 6, 2022
ad5eef1
try something
lithomas1 Aug 7, 2022
71ab88d
pin hypothesis
lithomas1 Aug 8, 2022
aca30a0
Don't check parentheses equality
lithomas1 Aug 8, 2022
11c9269
typo
lithomas1 Aug 8, 2022
5cfb071
pin cython
lithomas1 Aug 8, 2022
668c53e
correctly pin hypothesis
lithomas1 Aug 9, 2022
827a648
adjust test
lithomas1 Aug 10, 2022
5fb3daa
remove compiler flag
lithomas1 Aug 10, 2022
b1a58fe
typo'ed
lithomas1 Aug 11, 2022
c68f7e0
Merge branch 'main' into test-py311
lithomas1 Aug 12, 2022
fd17b61
Merge branch 'main' into test-py311
lithomas1 Aug 14, 2022
354b12c
fix tests
lithomas1 Aug 15, 2022
54023de
linter
lithomas1 Aug 15, 2022
78a4a46
Merge branch 'main' into test-py311
lithomas1 Aug 15, 2022
9adcc80
clarify freeze/unfreeze instructions
lithomas1 Aug 17, 2022
1ac995e
Merge branch 'main' into test-py311
lithomas1 Aug 17, 2022
ce6a0a4
whitespace
lithomas1 Aug 17, 2022
0b32782
one more
lithomas1 Aug 17, 2022
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
46 changes: 29 additions & 17 deletions .github/workflows/python-dev.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
# This file is purposely frozen(does not run). DO NOT DELETE IT
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better to leave the comment in, and just comment out the if: false below.

Copy link
Member

@mroeschke mroeschke Aug 12, 2022

Choose a reason for hiding this comment

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

Agreed. Even better to clarify

  1. "Freeze" if our dependencies don't support the latest python dev version
  2. "Unfreeze" if our dependencies support it, but the python dev version hasn't been officially released

Copy link
Member

Choose a reason for hiding this comment

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

@fangchenli Do you have any objections here?

Copy link
Member Author

Choose a reason for hiding this comment

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

@fangchenli Do you have any objections here?

No, I agree with you and @mroeschke

# Unfreeze(by commentingthe if: false() condition) once the
# next Python Dev version has released beta 1 and both Cython and numpy support it
# After that Python has released, migrate the workflows to the
# posix GHA workflows and "freeze" this file by
# uncommenting the if: false() condition
# This workflow may or may not run depending on the state of the next
# unreleased Python version. DO NOT DELETE IT.
#
# In general, this file will remain frozen(present, but not running) until:
# - The next unreleased Python version has released beta 1
# - This version should be available on Github Actions.
# - Our required build/runtime dependencies(numpy, pytz, Cython, python-dateutil)
# support that unreleased Python version.
# To unfreeze, comment out the ``if: false`` condition, and make sure you update
# the name of the workflow and Python version in actions/setup-python to: '3.12-dev'
#
# After it has been unfrozen, this file should remain unfrozen(present, and running) until:
# - The next Python version has been officially released.
# OR
# - Most/All of our optional dependencies support Python 3.11 AND
# - The next Python version has released a rc(we are guaranteed a stable ABI).
# To freeze this file, uncomment out the ``if: false`` condition, and migrate the jobs
# to the corresponding posix/windows-macos/sdist etc. workflows.
# Feel free to modify this comment as necessary.

name: Python Dev
Expand Down Expand Up @@ -32,7 +44,7 @@ permissions:

jobs:
build:
if: false # Comment this line out to "unfreeze"
# if: false # Uncomment this to freeze the workflow, comment it to unfreeze
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -53,27 +65,27 @@ jobs:
fetch-depth: 0

- name: Set up Python Dev Version
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: '3.11-dev'

- name: Install dependencies
shell: bash -el {0}
run: |
python3 -m pip install --upgrade pip setuptools wheel
python3 -m pip install -i https://pypi.anaconda.org/scipy-wheels-nightly/simple numpy
python3 -m pip install git+https://github.com/nedbat/coveragepy.git
python3 -m pip install cython python-dateutil pytz hypothesis pytest>=6.2.5 pytest-xdist pytest-cov pytest-asyncio>=0.17
python3 -m pip list
python --version
python -m pip install --upgrade pip setuptools wheel
python -m pip install git+https://github.com/numpy/numpy.git
python -m pip install git+https://github.com/nedbat/coveragepy.git
python -m pip install python-dateutil pytz cython hypothesis==6.52.1 pytest>=6.2.5 pytest-xdist pytest-cov pytest-asyncio>=0.17
python -m pip list

- name: Build Pandas
run: |
python3 setup.py build_ext -q -j2
python3 -m pip install -e . --no-build-isolation --no-use-pep517
python setup.py build_ext -q -j2
python -m pip install -e . --no-build-isolation --no-use-pep517

- name: Build Version
run: |
python3 -c "import pandas; pandas.show_versions();"
python -c "import pandas; pandas.show_versions();"

- name: Test
uses: ./.github/actions/run-tests
1 change: 1 addition & 0 deletions pandas/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

PY39 = sys.version_info >= (3, 9)
PY310 = sys.version_info >= (3, 10)
PY311 = sys.version_info >= (3, 11)
PYPY = platform.python_implementation() == "PyPy"
IS64 = sys.maxsize > 2**32

Expand Down
15 changes: 13 additions & 2 deletions pandas/tests/arrays/categorical/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import numpy as np
import pytest

from pandas.compat import PY311

from pandas import (
Categorical,
CategoricalIndex,
Expand Down Expand Up @@ -61,7 +63,11 @@ def test_set_ordered(self):
assert not cat2.ordered

# removed in 0.19.0
msg = "can't set attribute"
msg = (
"property 'ordered' of 'Categorical' object has no setter"
if PY311
else "can't set attribute"
)
with pytest.raises(AttributeError, match=msg):
cat.ordered = True
with pytest.raises(AttributeError, match=msg):
Expand Down Expand Up @@ -515,7 +521,12 @@ def test_codes_immutable(self):
tm.assert_numpy_array_equal(c.codes, exp)

# Assignments to codes should raise
with pytest.raises(AttributeError, match="can't set attribute"):
msg = (
"property 'codes' of 'Categorical' object has no setter"
if PY311
else "can't set attribute"
)
with pytest.raises(AttributeError, match=msg):
c.codes = np.array([0, 1, 2, 0, 1], dtype="int8")

# changes in the codes array should raise
Expand Down
5 changes: 4 additions & 1 deletion pandas/tests/indexes/datetimes/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,10 @@ def test_timestamp_constructor_retain_fold(tz, fold):

_tzs = ["dateutil/Europe/London"]
if PY39:
_tzs = ["dateutil/Europe/London", zoneinfo.ZoneInfo("Europe/London")]
try:
_tzs = ["dateutil/Europe/London", zoneinfo.ZoneInfo("Europe/London")]
except zoneinfo.ZoneInfoNotFoundError:
pass


@pytest.mark.parametrize("tz", _tzs)
Expand Down
10 changes: 9 additions & 1 deletion pandas/tests/indexes/multi/test_get_set.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import numpy as np
import pytest

from pandas.compat import PY311

from pandas.core.dtypes.dtypes import DatetimeTZDtype

import pandas as pd
Expand Down Expand Up @@ -139,9 +141,15 @@ def test_set_levels_codes_directly(idx):
minor_codes = [(x + 1) % 1 for x in minor_codes]
new_codes = [major_codes, minor_codes]

msg = "[Cc]an't set attribute"
msg = "Can't set attribute"
with pytest.raises(AttributeError, match=msg):
idx.levels = new_levels

msg = (
"property 'codes' of 'MultiIndex' object has no setter"
if PY311
else "can't set attribute"
)
with pytest.raises(AttributeError, match=msg):
idx.codes = new_codes

Expand Down
9 changes: 8 additions & 1 deletion pandas/tests/indexes/period/test_freq_attr.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pytest

from pandas.compat import PY311

from pandas import (
offsets,
period_range,
Expand All @@ -17,5 +19,10 @@ def test_freq_setter_deprecated(self):
idx.freq

# warning for setter
with pytest.raises(AttributeError, match="can't set attribute"):
msg = (
"property 'freq' of 'PeriodArray' object has no setter"
if PY311
else "can't set attribute"
)
with pytest.raises(AttributeError, match=msg):
idx.freq = offsets.Day()
11 changes: 9 additions & 2 deletions pandas/tests/io/parser/common/test_read_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import numpy as np
import pytest

from pandas.compat import PY311
from pandas.errors import (
EmptyDataError,
ParserError,
Expand Down Expand Up @@ -224,13 +225,19 @@ def test_read_csv_wrong_num_columns(all_parsers):
parser.read_csv(StringIO(data))


def test_null_byte_char(all_parsers):
def test_null_byte_char(request, all_parsers):
# see gh-2741
data = "\x00,foo"
names = ["a", "b"]
parser = all_parsers

if parser.engine == "c":
if parser.engine == "c" or (parser.engine == "python" and PY311):
if parser.engine == "python" and PY311:
request.node.add_marker(
pytest.mark.xfail(
reason="In Python 3.11, this is read as an empty character not null"
)
)
expected = DataFrame([[np.nan, "foo"]], columns=names)
out = parser.read_csv(StringIO(data), names=names)
tm.assert_frame_equal(out, expected)
Expand Down
10 changes: 8 additions & 2 deletions pandas/tests/io/parser/test_quoting.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import pytest

from pandas.compat import PY311
from pandas.errors import ParserError

from pandas import DataFrame
Expand Down Expand Up @@ -80,11 +81,16 @@ def test_null_quote_char(all_parsers, quoting, quote_char):

if quoting != csv.QUOTE_NONE:
# Sanity checking.
msg = "quotechar must be set if quoting enabled"
msg = (
'"quotechar" must be a 1-character string'
if PY311 and all_parsers.engine == "python" and quote_char == ""
else "quotechar must be set if quoting enabled"
)

with pytest.raises(TypeError, match=msg):
parser.read_csv(StringIO(data), **kwargs)
else:
elif not (PY311 and all_parsers.engine == "python"):
# Python 3.11+ doesn't support null/blank quote chars in their csv parsers
expected = DataFrame([[1, 2, 3]], columns=["a", "b", "c"])
result = parser.read_csv(StringIO(data), **kwargs)
tm.assert_frame_equal(result, expected)
Expand Down