TaggedScalar.value has an unknown type
ruamel.yaml is a YAML 1.2 parser/emitter for Python
Brought to you by:
anthon
In ruamel.yaml 0.19.1, strict Pyright cannot determine the type of the public TaggedScalar.value attribute:
from ruamel.yaml.comments import TaggedScalar
def payload(value: TaggedScalar) -> str:
return value.value
This reports reportUnknownMemberType and reportUnknownVariableType. TaggedScalar.str, count, and getitem also return Any.
Ticket #361 confirms that parser-produced tagged scalar values being strings is deliberate. These attributes and methods can therefore have precise string-based annotations. The constructor currently defaults value to None, so the implementation should also establish a valid string state rather than merely annotating a value that can still be None.
Implemented in merge request #17. The change gives TaggedScalar.value and its string-like methods precise types and makes default construction establish a valid string state. The strict Pyright reproducer and full Python 3.9/3.14 test suites pass.