hakancelikdev / unimport

:rocket: The ultimate linter and formatter for removing unused import statements in your code.
https://unimport.hakancelik.dev/
MIT License
239 stars 22 forks source link

`unimport` with no options and no config file produces an error #281

Closed mxr closed 1 year ago

mxr commented 1 year ago

See below output:

$ unimport example.py
Traceback (most recent call last):
  File "/Users/mxr/tmp/venv3.7/bin/unimport", line 8, in <module>
    sys.exit(main())
  File "/Users/mxr/tmp/venv3.7/lib/python3.7/site-packages/unimport/__main__.py", line 6, in main
    main = Main.run()
  File "/Users/mxr/tmp/venv3.7/lib/python3.7/site-packages/unimport/main.py", line 107, in run
    self = cls(argv)
  File "<string>", line 4, in __init__
  File "/Users/mxr/tmp/venv3.7/lib/python3.7/site-packages/unimport/main.py", line 39, in __post_init__
    self.config = self.argv_to_config()
  File "/Users/mxr/tmp/venv3.7/lib/python3.7/site-packages/unimport/main.py", line 47, in argv_to_config
    commands.generate_parser().parse_args(self.argv if self.argv is not None else sys.argv[1:])
  File "/Users/mxr/tmp/venv3.7/lib/python3.7/site-packages/unimport/config.py", line 194, in parse_args
    config_context = cls(Path(path)).parse()
  File "<string>", line 4, in __init__
  File "/Users/mxr/tmp/venv3.7/lib/python3.7/site-packages/unimport/config.py", line 127, in __post_init__
    raise FileNotFoundError(f"Config file not found: {self.config_file}")
FileNotFoundError: Config file not found: setup.cfg

Perhaps unimport could have some default useful/silent behavior in the presence of no options and no config?