Skip to content

Commit 335aec6

Browse files
committed
Minor tweaks
1 parent bb8a556 commit 335aec6

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

src/uproot/writing/writable.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2262,10 +2262,7 @@ def _is_type_specification(obj):
22622262
continue
22632263
try:
22642264
awkward.types.from_datashape(obj, highlevel=False)
2265-
except (
2266-
awkward.types._awkward_datashape_parser.UnexpectedToken,
2267-
awkward.types._awkward_datashape_parser.UnexpectedCharacters,
2268-
):
2265+
except Exception:
22692266
pass
22702267
else:
22712268
continue
@@ -2282,9 +2279,7 @@ def _type_specification_to_awkward_form(obj):
22822279
try:
22832280
obj = numpy.dtype(obj)
22842281
except (TypeError, ValueError):
2285-
raise TypeError(
2286-
f"Cannot construct a NumPy dtype from {obj!r} of type {type(obj).__name__}."
2287-
) from None
2282+
raise TypeError(f"Cannot construct a NumPy dtype from {obj!r}.") from None
22882283
if isinstance(obj, tuple):
22892284
try:
22902285
obj = numpy.dtype(obj)
@@ -2294,7 +2289,7 @@ def _type_specification_to_awkward_form(obj):
22942289
) from None
22952290
if isinstance(obj, str):
22962291
# First we try to interpret the string as a NumPy dtype
2297-
# so we can try to convert it to a string Awkward unterstands
2292+
# so we can try to convert it to a string Awkward understands
22982293
try:
22992294
dt = numpy.dtype(obj)
23002295
except (TypeError, ValueError):
@@ -2316,10 +2311,7 @@ def _type_specification_to_awkward_form(obj):
23162311
return awkward.forms.from_type(
23172312
awkward.types.from_datashape(obj, highlevel=False)
23182313
)
2319-
except (
2320-
awkward.types._awkward_datashape_parser.UnexpectedToken,
2321-
awkward.types._awkward_datashape_parser.UnexpectedCharacters,
2322-
):
2314+
except Exception:
23232315
raise TypeError(
23242316
f"Cannot construct an Awkward Form from type specification {obj!r}"
23252317
) from None

tests/test_1604_write_tuple_dtypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def test_unsupported_numpy_dtypes(tmp_path):
105105
# using some random type should not work
106106
dt_unknown = frozenset
107107
with pytest.raises(TypeError):
108-
file.mktree("tree4", {"x": dt_tuple})
108+
file.mktree("tree4", {"x": dt_unknown})
109109
with pytest.raises(TypeError):
110110
file.mkrntuple("ntuple4", {"x": dt_unknown})
111111

0 commit comments

Comments
 (0)