MAINT: Adding ruff unsafe-fixes - #236
Conversation
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
ev-br
left a comment
There was a problem hiding this comment.
I'd like to understand why these are unsfafe-fixes. The changes seem to be of two groups:
- typing
-> Arrayreplaced by-> Self(ok whatever)
This should be perfectly safe at runtime - nested ifs collapsed with either
andorisinstance(object, tuple_of_types)
The former form shortcuts fine, the latter... probably shortcuts too, not sure.
Plus benign refactors ofif-elseinto adict.getetc.
And if it's labeled as unsafe, it means I don't see something, so what is it I'm not seeing: Which of these is unsafe and how?
See: https://docs.astral.sh/ruff/linter/#fix-safety I think for the first part: the conditional import is something that I added manually; originally Ruff just imported For the second part, I'm not sure about it either. |
|
Thanks for the link. My question is still why these fixes are "unsafe" in the meaning of that link: what are the changes to the runtime behaviour. |
|
Thanks for digging through their docs! It all makes sense now. |
Totally agreed! |
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
|
Also added some comments in |
|
Thank you @prady0t , merged. |
Towards #228