|
22 | 22 |
|
23 | 23 | import itk
|
24 | 24 | import itk.support.types as itkt
|
25 |
| -from sys import argv |
| 25 | +from sys import argv, version_info |
26 | 26 | import warnings
|
27 |
| -from typing import Sequence, TypeVar, get_type_hints, get_args, get_origin, Union |
| 27 | + |
| 28 | +if version_info >= (3, 8): |
| 29 | + from typing import Sequence, TypeVar, get_type_hints, get_args, get_origin, Union |
| 30 | +else: |
| 31 | + from typing import Sequence, TypeVar, Union |
| 32 | + |
28 | 33 |
|
29 | 34 | try:
|
30 | 35 | from numpy.typing import ArrayLike
|
|
52 | 57 | compare_filter.Update()
|
53 | 58 | assert compare_filter.GetMaximumDifference() < 0.000000001
|
54 | 59 |
|
55 |
| -# Check the type hints |
56 |
| -type_hints = get_type_hints(itk.median_image_filter, globalns={"itk": itk}) |
| 60 | +if version_info >= (3, 8): |
| 61 | + # Check the type hints |
| 62 | + type_hints = get_type_hints(itk.median_image_filter, globalns={"itk": itk}) |
57 | 63 |
|
58 |
| -assert "args" in type_hints |
59 |
| -args_hints = type_hints["args"] |
60 |
| -assert get_origin(args_hints) is Union |
61 |
| -assert itk.ImageBase in get_args(args_hints) |
| 64 | + assert "args" in type_hints |
| 65 | + args_hints = type_hints["args"] |
| 66 | + assert get_origin(args_hints) is Union |
| 67 | + assert itk.ImageBase in get_args(args_hints) |
62 | 68 |
|
63 |
| -assert "radius" in type_hints |
64 |
| -radius_hints = type_hints["radius"] |
65 |
| -assert get_origin(radius_hints) is Union |
66 |
| -assert int in get_args(radius_hints) |
67 |
| -assert Sequence[int] in get_args(radius_hints) |
| 69 | + assert "radius" in type_hints |
| 70 | + radius_hints = type_hints["radius"] |
| 71 | + assert get_origin(radius_hints) is Union |
| 72 | + assert int in get_args(radius_hints) |
| 73 | + assert Sequence[int] in get_args(radius_hints) |
68 | 74 |
|
69 |
| -assert "return" in type_hints |
70 |
| -result_hints = type_hints["return"] |
71 |
| -assert itk.ImageBase in get_args(args_hints) |
| 75 | + assert "return" in type_hints |
| 76 | + result_hints = type_hints["return"] |
| 77 | + assert itk.ImageBase in get_args(args_hints) |
72 | 78 |
|
73 |
| -# Check for process_object attribute pointing to the associated class |
74 |
| -assert itk.median_image_filter.process_object is itk.MedianImageFilter |
| 79 | + # Check for process_object attribute pointing to the associated class |
| 80 | + assert itk.median_image_filter.process_object is itk.MedianImageFilter |
75 | 81 |
|
76 | 82 |
|
77 | 83 | # Test that `__call__()` inside itkTemplate is deprecated. Replaced
|
|
0 commit comments