With ruamel.yaml 0.19.1, Pyright 1.1.411 in strict mode, and Python 3.14.4 on macOS, ordinary access to collection comment and source-position metadata is reported as Unknown.
Minimal example (example.py):
from ruamel.yaml.comments import CommentedMap
def inspect_metadata(value: CommentedMap) -> None:
reveal_type(value.ca)
reveal_type(value.lc)
reveal_type(value.lc.col)
Run pyright example.py with typeCheckingMode set to strict in pyrightconfig.json. Output:
Type of "ca" is unknown (reportUnknownMemberType)
Type of "value.ca" is "Unknown"
Type of "lc" is unknown (reportUnknownMemberType)
Type of "value.lc" is "Unknown"
Type of "lc" is unknown (reportUnknownMemberType)
Type of "col" is unknown (reportUnknownMemberType)
Type of "value.lc.col" is "Unknown"
4 errors, 0 warnings, 3 informations
Expected: the properties expose their concrete metadata classes (Comment and LineCol), with useful annotations for their members. LineCol.col should reflect its actual lifecycle, including None before a source location is populated. Comment association fields also need types that describe their heterogeneous token slots.
In comments.py, ca has a legacy # type: () -> Any comment and lc is annotated as Any. The typing imports are also hidden under if False, as described in ticket #511: https://sourceforge.net/p/ruamel-yaml/tickets/511/ . Fixing those imports alone would still leave these properties as Any rather than concrete metadata types.
This prevents downstream code from accessing .ca and .lc.col directly under strict typing. Literalizer currently needs small protocol-typed adapter functions to describe the metadata on parsed collections: https://github.com/adamtheturtle/literalizer/pull/5023 . Precise upstream property/member annotations would let us remove those adapters.