github
1 of 1 new or added line in 1 file covered. (100.0%)
9 existing lines in 1 file now uncovered.1146 of 1211 relevant lines covered (94.63%)
4.69 hits per line
1 |
"""This module provides a compatibility layer for functions in typing that appeared on 3.8"""
|
|
2 |
import collections.abc |
5✔ |
3 |
import sys |
5✔ |
4 |
|
|
5 |
if sys.version_info[:2] > (3, 7): |
5✔ |
6 |
from typing import get_args, get_origin |
4✔ |
7 |
|
|
8 |
else:
|
|
UNCOV
9
|
def get_origin(tp): |
1✔ |
UNCOV
10
|
if hasattr(tp, '__origin__'): |
1✔ |
UNCOV
11
|
return tp.__origin__
|
1✔ |
UNCOV
12
|
return None |
1✔ |
13 |
|
|
14 |
|
|
UNCOV
15
|
def get_args(tp): |
1✔ |
UNCOV
16
|
if hasattr(tp, '__args__'): |
1✔ |
UNCOV
17
|
res = tp.__args__ |
1✔ |
UNCOV
18
|
if get_origin(tp) is collections.abc.Callable and res[0] is not Ellipsis: |
1✔ |
19 |
res = (list(res[:-1]), res[-1]) |
× |
UNCOV
20
|
return res
|
1✔ |
21 |
return ()
|
× |