Skip to content

Versioned branch fixer removes comments after if block #970

@adamchainz

Description

@adamchainz

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 .)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions