Skip to content

Commit eddd327

Browse files
Use string type annotations for Python 3.11 not 3.10 (#420)
Use string type annotations for Python 3.11 not 3.10, as PEP 563 has been postponed to Python 3.11 https://mail.python.org/archives/list/[email protected]/thread/CLVXXPQ2T2LQ5MP2Y53VVQFCXYWQJHKZ/ Additionally: - add a CI entry testing cloudpickle against Python 3.10 (which was currently done in the python-nightly entry of the cloudpickle CI) - make the python-nightly entry test cloudpickle against Python 3.11, but make this entry temporarily optional because of the current instability of Python 3.11 (see the the #420 thread for additional details on this topic)
1 parent 6e0f571 commit eddd327

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

.github/workflows/testing.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
strategy:
3030
matrix:
3131
os: [ubuntu-latest, windows-latest, macos-latest]
32-
python_version: [3.5, 3.6, 3.7, 3.8, 3.9, "pypy3"]
32+
python_version: [3.5, 3.6, 3.7, 3.8, 3.9, "3.10-dev", "pypy3"]
3333
exclude:
3434
# Do not test all minor versions on all platforms, especially if they
3535
# are not the oldest/newest supported versions
@@ -58,7 +58,7 @@ jobs:
5858
steps:
5959
- uses: actions/checkout@v1
6060
- name: Set up Python ${{ matrix.python_version }}
61-
uses: actions/setup-python@v1
61+
uses: actions/setup-python@v2
6262
with:
6363
python-version: ${{ matrix.python_version }}
6464
- name: Install project and dependencies
@@ -96,14 +96,16 @@ jobs:
9696

9797
python-nightly:
9898
runs-on: ubuntu-18.04
99+
# This entry is made optional for now, see https://github.com/cloudpipe/cloudpickle/pull/420
100+
if: "contains(github.event.pull_request.labels.*.name, 'ci python-nightly')"
99101
steps:
100102
- uses: actions/checkout@v1
101103
- name: Install Python from ppa:deadsnakes/nightly
102104
run: |
103105
sudo add-apt-repository ppa:deadsnakes/nightly
104106
sudo apt update
105-
sudo apt install python3.10 python3.10-venv python3.10-dev
106-
python3.10 -m venv nightly-venv
107+
sudo apt install python3.11 python3.11-venv python3.11-dev
108+
python3.11 -m venv nightly-venv
107109
echo "$PWD/nightly-venv/bin" >> $GITHUB_PATH
108110
- name: Display Python version
109111
run: python -c "import sys; print(sys.version)"

tests/cloudpickle_test.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2207,10 +2207,13 @@ def method(self, arg: type_) -> type_:
22072207

22082208
def check_annotations(obj, expected_type, expected_type_str):
22092209
assert obj.__annotations__["attribute"] == expected_type
2210-
if sys.version_info >= (3, 10):
2211-
# In Python 3.10, type annotations are stored as strings.
2210+
if sys.version_info >= (3, 11):
2211+
# In Python 3.11, type annotations are stored as strings.
22122212
# See PEP 563 for more details:
22132213
# https://www.python.org/dev/peps/pep-0563/
2214+
# Originaly scheduled for 3.10, then postponed.
2215+
# See this for more details:
2216+
# https://mail.python.org/archives/list/[email protected]/thread/CLVXXPQ2T2LQ5MP2Y53VVQFCXYWQJHKZ/
22142217
assert (
22152218
obj.method.__annotations__["arg"]
22162219
== expected_type_str

0 commit comments

Comments
 (0)