Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 2 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ jobs:
run: |
sudo add-apt-repository ppa:deadsnakes/nightly
sudo apt update
sudo apt install python3.9 python3.9-venv python3.9-dev
python3.9 -m venv nightly-venv
sudo apt install python3.10 python3.10-venv python3.10-dev
python3.10 -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
22 changes: 15 additions & 7 deletions tests/cloudpickle_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2205,17 +2205,25 @@ def method(self, arg: type_) -> type_:
return arg
MyClass.__annotations__ = {'attribute': type_}

def check_annotations(obj, expected_type):
def check_annotations(obj, expected_type, expected_type_str):
assert obj.__annotations__["attribute"] == expected_type
assert obj.method.__annotations__["arg"] == expected_type
assert (
obj.method.__annotations__["return"] == expected_type
)
if sys.version_info >= (3, 10):
# In Python 3.10, type annotations are stored as strings.
# See PEP 563 for more details: https://www.python.org/dev/peps/pep-0563/
assert obj.method.__annotations__["arg"] == expected_type_str
assert (
obj.method.__annotations__["return"] == expected_type_str
)
else:
assert obj.method.__annotations__["arg"] == expected_type
assert (
obj.method.__annotations__["return"] == expected_type
)
Comment thread
ogrisel marked this conversation as resolved.
return "ok"

obj = MyClass()
assert check_annotations(obj, type_) == "ok"
assert worker.run(check_annotations, obj, type_) == "ok"
assert check_annotations(obj, type_, "type_") == "ok"
assert worker.run(check_annotations, obj, type_, "type_") == "ok"
Comment thread
ogrisel marked this conversation as resolved.
Outdated

def test_generic_extensions_literal(self):
typing_extensions = pytest.importorskip('typing_extensions')
Expand Down