alecthomas / importmagic

A Python library for finding unresolved symbols in Python code, and the corresponding imports
BSD 2-Clause "Simplified" License
120 stars 20 forks source link

Provide CLI interface to apply import magic on a file? #45

Closed ChillarAnand closed 6 years ago

alecthomas commented 7 years ago

Could be useful. I'd accept a patch that made this mojo happen.

razzius commented 6 years ago

I opened a PR with my take on an importmagic script. It's pretty basic but gets the job done.

Here's what it looks like:

$ importmagic
usage: importmagic [-h] [--refresh] [--exclude-current-path] file_name
importmagic: error: the following arguments are required: file_name
$ importmagic myfile.py
$ importmagic myfile.py --refresh
razzius commented 6 years ago

I'm sure one feature people would like would be the ability to say whether or not the file should be overwritten in-place (-i option). In fact it should probably be the default to print rather than overwrite.

alecthomas commented 6 years ago

Merged, thanks!