49
49
50
50
dataclass_options = {"frozen" : True }
51
51
52
- # we'll need this because python can't tell if kwargs are passed in not
53
- DEFAULT = object ()
52
+
53
+ # Needed for cases where `None` can be an appropriate kwarg value,
54
+ # we override the meta so that it looks good in the docs.
55
+ class NotSetMeta (type ):
56
+ def __repr__ (cls ):
57
+ return "Not set"
58
+
59
+
60
+ class NOTSET (metaclass = NotSetMeta ):
61
+ pass
54
62
55
63
56
64
@metadata .lazy_decode
@@ -590,7 +598,7 @@ def _update_metadata_schema_cache_from_ll(self) -> None:
590
598
self .ll_table .metadata_schema
591
599
)
592
600
593
- def metadata_vector (self , key , * , dtype = None , default_value = DEFAULT ):
601
+ def metadata_vector (self , key , * , dtype = None , default_value = NOTSET ):
594
602
"""
595
603
Returns a numpy array of metadata values obtained by extracting ``key``
596
604
from each metadata entry, and using ``default_value`` if the key is
@@ -602,10 +610,11 @@ def metadata_vector(self, key, *, dtype=None, default_value=DEFAULT):
602
610
:param str dtype: The dtype of the result (can usually be omitted).
603
611
:param object default_value: The value to be inserted if the metadata key
604
612
is not present. Note that for numeric columns, a default value of None
605
- will result in a non-numeric array.
613
+ will result in a non-numeric array. The default behaviour is to raise
614
+ ``KeyError`` on missing entries.
606
615
"""
607
616
608
- if default_value == DEFAULT :
617
+ if default_value == NOTSET :
609
618
610
619
def getter (d , k ):
611
620
return d [k ]
0 commit comments