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

Use string type annotations for Python 3.11 not 3.10 #420

Merged
merged 7 commits into from Jun 19, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/workflows/testing.yml
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
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