hadialqattan / pycln

A formatter for finding and removing unused import statements.

Home Page:https://hadialqattan.github.io/pycln

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] incorrectly removing trailing `pass`.

sunmy2019 opened this issue · comments

To Reproduce Steps to reproduce the behavior:

  1. Take this code snippet:
import random
import time


def foo():
    pass


if random.randint(0, 1):
    foo()
    if random.randint(0, 1):
        foo()
else:
    pass
  1. Run this Pycln command:
 $ python3.8 -m pycln test.py
  1. Unexpected fixed code (if present):
import random


def foo():
    pass


if random.randint(0, 1):
    foo()
    if random.randint(0, 1):
        foo()
else:

Expected behavior:

The generated python code should be legal.

Environment (please complete the following informations):

  • Python Version: python3.8
  • Pycln Version: pycln, version 1.1.0
  • OS Type: Linux

Duplicated #99

This already has been solved in v1.2.2