-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
E731: Introduction of invalid indentation #4924
Comments
This is occurring because the |
Yeah it might be tough right now. We have to find the indentation of the containing block. (This is an unlikely bug in practice but it should definitely be fixed when possible.) |
Er, so this no longer seems to trigger a tab inconsistency error. Local python accepts it no problem, and ruff no longer emits a panic about generating invalid content. Solved? 😝 |
Just to clarify the state of this issue:
It's hard for me to imagine a situation where this would arise in "real world" code. It may be that other issues arise where it becomes clear that we want the generator to know about "local" styles, in which case this problem would be solved - but this particular case doesn't quite seem like motivation enough to introduce that functionality. I would vote to close this as unplanned. What do others think? |
Yeah, it'll also make the |
Python 3 allows for the use of different indentation styles, provided that they remain consistent within a single block and do not add tabs after spaces.
E731 fix may introduce invalid indentation if the indentation choice in the first block does not match the indentation of the block in which the fix is applied. As an example:
a
uses tabs,b
uses spaces. Ruff infers the indentation from the first observed, so the replacement suggested is:The inner function
c
uses tabs, which triggers a tab inconsistency syntax error.This was discovered by #4822.
The text was updated successfully, but these errors were encountered: