Skip to content

Commit

Permalink
Use string type annotations for Python 3.11 not 3.10 (#420)
Browse files Browse the repository at this point in the history
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/python-dev@python.org/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)
  • Loading branch information
frenzymadness authored Jun 19, 2021
1 parent 6e0f571 commit eddd327
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python_version: [3.5, 3.6, 3.7, 3.8, 3.9, "pypy3"]
python_version: [3.5, 3.6, 3.7, 3.8, 3.9, "3.10-dev", "pypy3"]
exclude:
# Do not test all minor versions on all platforms, especially if they
# are not the oldest/newest supported versions
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python_version }}
- name: Install project and dependencies
Expand Down Expand Up @@ -96,14 +96,16 @@ jobs:

python-nightly:
runs-on: ubuntu-18.04
# This entry is made optional for now, see https://github.com/cloudpipe/cloudpickle/pull/420
if: "contains(github.event.pull_request.labels.*.name, 'ci python-nightly')"
steps:
- uses: actions/checkout@v1
- name: Install Python from ppa:deadsnakes/nightly
run: |
sudo add-apt-repository ppa:deadsnakes/nightly
sudo apt update
sudo apt install python3.10 python3.10-venv python3.10-dev
python3.10 -m venv nightly-venv
sudo apt install python3.11 python3.11-venv python3.11-dev
python3.11 -m venv nightly-venv
echo "$PWD/nightly-venv/bin" >> $GITHUB_PATH
- name: Display Python version
run: python -c "import sys; print(sys.version)"
Expand Down
7 changes: 5 additions & 2 deletions tests/cloudpickle_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2207,10 +2207,13 @@ def method(self, arg: type_) -> type_:

def check_annotations(obj, expected_type, expected_type_str):
assert obj.__annotations__["attribute"] == expected_type
if sys.version_info >= (3, 10):
# In Python 3.10, type annotations are stored as strings.
if sys.version_info >= (3, 11):
# In Python 3.11, type annotations are stored as strings.
# See PEP 563 for more details:
# https://www.python.org/dev/peps/pep-0563/
# Originaly scheduled for 3.10, then postponed.
# See this for more details:
# https://mail.python.org/archives/list/python-dev@python.org/thread/CLVXXPQ2T2LQ5MP2Y53VVQFCXYWQJHKZ/
assert (
obj.method.__annotations__["arg"]
== expected_type_str
Expand Down

0 comments on commit eddd327

Please sign in to comment.