File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 1212import copy
1313import uuid
1414import collections
15+ try :
16+ from collections import abc
17+ except ImportError :
18+ import collections as abc
1519
1620import numpy as np
1721
2327_VALID_URLS .discard ('' )
2428
2529
30+ def _is_sized_iterable (arg ):
31+ """Validates the arg is Sized & Iterable"""
32+ return isinstance (arg , abc .Sized ) & isinstance (arg , abc .Iterable )
33+
34+
2635def _validate_location (location ):
2736 """Validates and formats location values before setting."""
28- if not isinstance (location , collections . abc . Collection ):
37+ if not _is_sized_iterable (location ):
2938 raise TypeError ('Expected a collection object for location, got '
3039 '{!r}' .format (location ))
3140 if len (location ) != 2 :
@@ -58,7 +67,7 @@ def _iter_tolist(x):
5867
5968def _flatten (container ):
6069 for i in container :
61- if isinstance ( i , collections . abc . Collection ):
70+ if _is_sized_iterable ( i ):
6271 for j in _flatten (i ):
6372 yield j
6473 else :
You can’t perform that action at this time.
0 commit comments