Skip to content

pyright change breaks intended usage of attrs.NOTHING #1339

@Sharp-Eyes

Description

@Sharp-Eyes

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 microsoft/pyright#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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    TypingTyping/stub/Mypy/PyRight related bugs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions