Skip to content

Conversation

dylwil3
Copy link
Collaborator

@dylwil3 dylwil3 commented Sep 25, 2025

In #7047 some logic was added to comment placement in order to address a panic in #6898 . I believe that panic was caused by old behavior of SimpleTokenizer that is no longer present, because it does not occur if the new logic is simply removed.

This was discovered while trying to figure out the potential side-effects of #20578 - I originally was going to augment the logic to include t-strings here, but discovered that you could instead just remove it (unless I missed something?)

@dylwil3 dylwil3 added the internal An internal refactor or improvement label Sep 25, 2025
Copy link
Contributor

ruff-ecosystem results

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@MichaReiser
Copy link
Member

MichaReiser commented Sep 26, 2025

It's very likely that this code is unused but it might be for a different reason than outlined in the PR and I'd prefer to fully understand why before removing this code.

I believe that panic was caused by old behavior of SimpleTokenizer that is no longer present, because it does not occur if the new logic is simply removed.

Can you explain what this new logic is? Reading #6898. My impression is that the issue is that the SimpleTokenizer doesn't support lexing strings. This hasn't changed.

To me, it also seems that the comment is still true because the interpolated element's range only covers {1} but maybe that's fine?

// These can't be parenthesized, as they must fall between two string tokens in an implicit
// concatenation. But the expression ranges only include the `1` and `2` above, so we also
// can't lex the contents between them.
if comment.enclosing_node().is_expr_f_string() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't comment there but doesn't this change result in the SimpleTokenizer trying to lex ' # comment on line 136. This would be invalid because the SimpleTokenizer should never be pointed inside a string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal An internal refactor or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants