Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyright change breaks intended usage of attrs.NOTHING #1339

Open
Sharp-Eyes opened this issue Aug 23, 2024 · 0 comments · May be fixed by #1358
Open

pyright change breaks intended usage of attrs.NOTHING #1339

Sharp-Eyes opened this issue Aug 23, 2024 · 0 comments · May be fixed by #1358
Labels
Typing Typing/stub/Mypy/PyRight related bugs.

Comments

@Sharp-Eyes
Copy link

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.

@hynek hynek added the Typing Typing/stub/Mypy/PyRight related bugs. label Aug 26, 2024
@Tinche Tinche linked a pull request Oct 13, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typing Typing/stub/Mypy/PyRight related bugs.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants