posit-dev / py-htmltools

Tools for HTML generation and output
MIT License
19 stars 4 forks source link

Make `TagAttrs` a `Mapping` #70

Open schloerke opened 12 months ago

schloerke commented 12 months ago
          I think a better way to go about this is to change `TagAttrs` from a `Dict` to a `Mapping`. (The reason it didn't accept a `TagAttrDict` as a `TagAttrs` object is because `Dict` is invariant, whereas `Mapping` is covariant.)
TagAttrs = Mapping[str, TagAttrValue]

There is also a place where you'll have to test for isinstance(x, Mapping) instead of isinstance(x, dict).

Originally posted by @wch in https://github.com/posit-dev/py-htmltools/issues/55#issuecomment-1791532660