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

[bug]: Deadcode --fix removes the f character from the from keyword in from module import (a,b,c,) #5

Open
vpatov opened this issue Jan 21, 2024 · 0 comments

Comments

@vpatov
Copy link

vpatov commented Jan 21, 2024

deadcode version:

[[package]]
name = "deadcode"
version = "2.2.2"
description = "Find and remove dead code."
category = "dev"
optional = false
python-versions = ">=3.8"
files = [
    {file = "deadcode-2.2.2-py3-none-any.whl", hash = "sha256:d8280cf44e224e47e061f9b9963b902c009dc1ba1e43a42623a43ab88e1afa36"},
    {file = "deadcode-2.2.2.tar.gz", hash = "sha256:b63e207999667e731212e04f6d48888a2e3f7256e5ee808ba9082af20d99dca0"},
]

Python version:

Python 3.11.7

To reproduce, create the following two files in the same directory:

file1.py:

foo = 1
bar = 2
xyz = 3

file2.py:

from file1 import (
    foo,
    bar,
    xyz
)

from file1 import foo

def fn():
    pass

fn()

Run deadcode with --fix

🐍 v3.11.7 (myapp-py3.11) 
✗  deadcode ./file2.py --fix
file2.py:1:0: DC007 Import `bar` is never used
file2.py:1:0: DC007 Import `foo` is never used
file2.py:1:0: DC007 Import `xyz` is never used
file2.py:7:0: DC007 Import `foo` is never used

Removed 4 unused code items!

I expect all of the imports to be removed, but this what file2.py looks like afterwards instead:

rom file1 import (
    foo,
    bar,
    xyz
)

def fn():
    pass

fn()

It removes the f in from, and doesn't get rid of those imports.

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

1 participant