Skip to content

Commit 231f5bb

Browse files
committed
Fix typing annotations for python 3.8
Queue does not accept type annotations and the tests running pytest was failing with ``` python -m pytest ... opensfm/features_processing.py:19: in <module> ProcessQueue = queue.Queue[ E TypeError: 'type' object is not subscriptable ... ``` Similar problem for networkx EdgeView
1 parent 874b6a8 commit 231f5bb

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

opensfm/features_processing.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import math
55
import queue
66
import threading
7+
import sys
78
from timeit import default_timer as timer
89
from typing import Any, cast, Dict, List, Optional, Tuple, Union
910

@@ -16,11 +17,16 @@
1617

1718
logger: logging.Logger = logging.getLogger(__name__)
1819

19-
ProcessQueue = queue.Queue[
20-
Optional[
21-
Tuple[str, NDArray, Optional[NDArray], Optional[NDArray], DataSetBase, bool]
20+
21+
if sys.version_info >= (3, 9):
22+
ProcessQueue = queue.Queue[
23+
Optional[
24+
Tuple[str, "NDArray", Optional["NDArray"], Optional["NDArray"], DataSetBase, bool]
25+
]
2226
]
23-
]
27+
else:
28+
ProcessQueue = queue.Queue
29+
2430
ProducerArgs = Tuple[
2531
ProcessQueue,
2632
DataSetBase,

opensfm/large/tools.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# pyre-strict
2+
from __future__ import annotations
23
import itertools
34
import logging
45
from functools import lru_cache

0 commit comments

Comments
 (0)