-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fixes for PYI061 and RUF020 can generate None | None
#14567
Comments
Hah, great catch (as ever). For reference, the CPython issue where it's debated whether we should change this behaviour at runtime in Python is python/cpython#107271. Regardless of whether we change it in a future version of CPython, however, this is clearly a bug in ruff, since the code does not raise an exception prior to the autofix but does afterwards. |
CC: @sbrugman (there's no expectation that you fix the issue, I just thought that you might be interested knowing about it) |
Nice catch. I'll look into it. |
The frustrating thing here is that if you have PYI016 also enabled, then this isn't an issue. But of course we can't mandate that users select rules in tandem like that. |
I'm exploring to fix this in a single go: if the parent union already contains the |
The fixes for
redundant-none-literal
(PYI061) andnever-union
(RUF020) in Ruff 0.8.0 can generateNone | None
, which raises an error at runtime.PYI061 example:
RUF020 example:
The text was updated successfully, but these errors were encountered: