Skip to content

Commit b4bcbb0

Browse files
authored
fix(test): replace collections.Callable, removed in Python 3.10 (#347)
test_client_try_import used `isinstance(x, collections.Callable)`. `collections.Callable` has been an alias for `collections.abc.Callable` since 3.3 and was removed in 3.10, so the test raises: AttributeError: module 'collections' has no attribute 'Callable' The suite therefore only passes on Python <= 3.9. .travis.yml tests 3.5/3.6/3.7, which is why this was never noticed -- and Travis has not run on this repo for a long time either. Uses the builtin `callable()` instead of `collections.abc.Callable`: same semantics (collections.abc.Callable.__subclasshook__ just checks for __call__), and it drops the now-unused `collections` import rather than keeping one around for a single predicate. Verified on Python 3.11.9: before 1 failed, 47 passed, 37 skipped after 48 passed, 37 skipped
1 parent a6dacfc commit b4bcbb0

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

‎tests/test_unit/test_core/test_client.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import pytest
55
import logging
6-
import collections
76
import requests_mock
87

98
from ucloud.client import Client
@@ -102,5 +101,5 @@ def test_client_try_import(client):
102101
continue
103102

104103
client_factory = getattr(client, name)
105-
if isinstance(client_factory, collections.Callable):
104+
if callable(client_factory):
106105
print(client_factory())

0 commit comments

Comments
 (0)