attrs
attrs copied to clipboard
pyright change breaks intended usage of attrs.NOTHING
attrs,Nothing is intended to be used as typing.Literal[NOTHING] as denoted in attr._make._Nothing. As of pyright version 1.1.371, this no longer works. As per https://github.com/microsoft/pyright/discussions/8820, this is an intentional change, and while it's a little unfortunate, it does make sense.
I think a sensible solution would be to expose attr._make._Nothing (for example by removing the leading underscore and exposing it in the relevant __init__.py files) and changing the intended usage to be something along the lines of
def foo(x: int | None | attrs.Nothing = attrs.NOTHING):
...
though this would be a somewhat breaking change; maybe it could be re-exported as a type alias instead.
Of course, there may very well be a better alternative that satisfies pyright that I have missed.