Comments (3)
The logic here caused the issue.
LibCST/libcst/codemod/visitors/_remove_imports.py
Lines 320 to 322 in 0ff9a6c
It removes imports when multiple import assignments are found. Not sure why it's implemented like this initially but it's not safe to do this. Especially the try: import ... except: import ...
is a common pattern in Python code.
The easiest way to fix it is to fix the logic in _is_in_use
.
from libcst.
Now this is fixed. @zsol, would you like to add your remove unused import VisitorBasedCodemodCommand
implementation? Then we can make it available in the next LibCST release. With that, everyone can use the CLI to run it over any repository: python3 -m libcst.tool codemod ...
from libcst.
Will do!
from libcst.
Related Issues (20)
- RemoveImportsVisitor crashes when parsing Literal["r+"] HOT 1
- Real-world code snippets which `libcst` fails to parse HOT 8
- A way to silence "Failed to determine module name"? HOT 2
- Support LSP for `TypeInferenceProvider` HOT 8
- Parse error when no space between keyword and float
- Parse error when non-standard indentation is encountered HOT 2
- Parse error when keyword adjacent to parenthesis
- ApplyTypeAnnotationVisitor should only annotate the first assignment to a name in a given scope HOT 1
- pip install -e gets the wrong version number HOT 2
- `QualifiedNameProvider` returns inner func name for higher-order anonymous func calls
- Publishing wheels for musl (alpine 3.17) HOT 1
- CSTNode.with_deep_changes type annotation is incomplete HOT 2
- Would be great if matchers somehow do automatic `ensure_type` HOT 1
- Incorrect expected type for second arg of `deep_replace`
- Sort functions by their usage? HOT 1
- Publishing the parser to crates.io HOT 8
- `CodeRange` provided by `PositionProvider` doesn't include decorators HOT 2
- Native parser crashes on pydoc_data.topics
- Codemod idea: change annotation strings to not strings
- Incorrect syntax error parsing contextmanagers HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libcst.