You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Consider emitting buffered DEDENT tokens on the last line #104976
Some final DEDENT tokens are now emitted within the bounds of the input. This means that for a file containing 3 lines, the old version of the tokenizer returned a DEDENT token in line 4 whilst the new version returns the token in line 3.
Apparently, this affects negatively some formatting tools (see PyCQA/pycodestyle#1142). Let's consider what options do we have and see if we can fix this without adding a lot of maintenance burden to the C tokenizer or slowing down everything.
Yeah, I think that, if we want to support doing the same thing as 3.11, the only way is to special-case it Python-tokenize.c and not in the C tokenizer itself.
Yeah, I think that, if we want to support doing the same thing as 3.11, the only way is to special-case it Python-tokenize.c and not in the C tokenizer itself.
Activity
pablogsal commentedon May 26, 2023
We can do something like this:
but I think this forces us to somehow handle the ENDMARKER internally. Maybe that's a possible solution but I fear this still has some side effects.
pablogsal commentedon May 26, 2023
@lysnikolaou thoughts?
pythongh-104976: Ensure trailing dedent tokens are emitted as the pre…
pablogsal commentedon May 26, 2023
CC: @mgmacias95
pablogsal commentedon May 26, 2023
Opened #104980 to test this idea
lysnikolaou commentedon May 26, 2023
Yeah, I think that, if we want to support doing the same thing as 3.11, the only way is to special-case it
Python-tokenize.cand not in the C tokenizer itself.pythongh-104976: Ensure trailing dedent tokens are emitted as the pre…
pythongh-104976: Ensure trailing dedent tokens are emitted as the pre…
pythongh-104976: Ensure trailing dedent tokens are emitted as the pre…
pablogsal commentedon May 26, 2023
Ok, then check if you like #104980
pythongh-104976: Ensure trailing dedent tokens are emitted as the pre…
pythongh-104976: Ensure trailing dedent tokens are emitted as the pre…
pythongh-104976: Ensure trailing dedent tokens are emitted as the pre…
pythongh-104976: Ensure trailing dedent tokens are emitted as the pre…
pythongh-104976: Ensure trailing dedent tokens are emitted as the pre…
gh-104976: Ensure trailing dedent tokens are emitted as the previous …
[3.12] gh-104976: Ensure trailing dedent tokens are emitted as the pr…