Skip to content
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

Versioned branch fixer removes comments after if block #970

Closed
adamchainz opened this issue Oct 10, 2024 · 4 comments
Closed

Versioned branch fixer removes comments after if block #970

adamchainz opened this issue Oct 10, 2024 · 4 comments

Comments

@adamchainz
Copy link
Contributor

The 'versioned branch' fixer currently removes comments after a dropped if block:

 import sys
 
-if sys.version_info < (3, 2):
-    print("3.2")
-
-# let's go
 print("ok")

The comment is outside of the block and should be preserved.

(Just fixed a similar issue in django-upgrade: adamchainz/django-upgrade#495 .)

@asottile
Copy link
Owner

there's a duplicate somewhere. this is relatively unfixable because there's no definitive end of a block

@adamchainz
Copy link
Contributor Author

Isn't this sufficient? #971 . It seems to, at least.

@BonaFideIT
Copy link

This could be the duplicate issue which @asottile mentioned: #931.

But I think @adamchainz is right, @asottile can you recheck this please?

@asottile
Copy link
Owner

there's a case that this creates a syntax error, I can't remember the exact one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants