evhub / coconut

Simple, elegant, Pythonic functional programming.
http://coconut-lang.org
Apache License 2.0
4.05k stars 120 forks source link

StyleError for unused imports quotes almost entire file in output #781

Closed yggdr closed 1 year ago

yggdr commented 1 year ago

When coconut finds an unused import, it quotes an error location from the point of the import statement (hence, most likely near the top of the file), until the end of file, making the output unnecessarily large and loquacious.

  Compiling         src/rechnungen/commands/latex.coco ...
  CoconutWarning: --incremental mode is not currently supported for files as large as {codepath!r}
  in src/rechnungen/commands/latex.coco:
    CoconutStyleError: found unused import 'yaml' (add '# NOQA' to suppress) (remove --strict to downgrade to a warning) (line
   26 in 'latex.coco')
      /~~~~~~~~~~

      import yaml

      import jinja2

[snip ca. 200 lines...]

              out = str(output_path)
              outdir = str(output_path.parent)

      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
  Coconut exiting with error: CoconutStyleError
evhub commented 1 year ago

Thanks for the bug report! Should be fixed as of coconut-develop>=3.0.3-post_dev6 (pip uninstall coconut and pip install -U coconut-develop).