Skip to content

Commit 0fd2426

Browse files
authored
Merge pull request #1611 from dougollerenshaw/fix/issue_1610
Fix typing.Protocol import in Python 3.8
2 parents a607dc0 + fbc73e5 commit 0fd2426

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

allensdk/core/typing.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
from typing import _Protocol
1+
import sys
2+
try:
3+
# for Python 3.8 and greater
4+
from typing import Protocol
5+
except ImportError:
6+
# for Python 3.7 and before
7+
from typing import _Protocol as Protocol
8+
29
from abc import abstractmethod
310

411

5-
class SupportsStr(_Protocol):
12+
class SupportsStr(Protocol):
613
"""Classes that support the __str__ method"""
714
@abstractmethod
815
def __str__(self) -> str:

0 commit comments

Comments
 (0)