Skip to content

Commit a86a1ec

Browse files
committed
Revert "Actually use tomllib for reading metadata"
This reverts commit 08de8c3.
1 parent 08de8c3 commit a86a1ec

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

lib/ts_utils/metadata.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,12 @@ def read_metadata(distribution: str) -> StubMetadata:
239239
"""
240240
try:
241241
with metadata_path(distribution).open("rb") as f:
242-
data: dict[str, object] = tomllib.load(f)
242+
# This cast is necessary for pyright to understand that the
243+
# variable is a dict with object values. Just using
244+
# `data: dict[str, object] = tomllib.load(f)` doesn't work because
245+
# pyright still infers TOMLDocument which derives from
246+
# dict[Unknown, Unknown].
247+
data = cast(dict[str, object], tomlkit.load(f))
243248
except FileNotFoundError:
244249
raise NoSuchStubError(f"Typeshed has no stubs for {distribution!r}!") from None
245250

0 commit comments

Comments
 (0)