attrs – how to validate an instance of a Literal or None
attrs – how to validate an instance of a Literal or None Question: This is what I have. I believe there are two problems here – the Literal and the None. from attrs import frozen, field from attrs.validators import instance_of OK_ARGS = [‘a’, ‘b’] @field class MyClass: my_field: Literal[OK_ARGS] | None = field(validator=instance_of((Literal[OK_ARGS], None))) Error: …