Zac-HD/shed

shed doesn't reformat .pyi files

jakkdl opened this issue ยท 3 comments

autoflake.is_python_file doesn't care about .pyi as a file ending, but I don't see why that's the case. Running Black or isort manually they both reformat .pyi, but shed uses autoflake's check and totally ignores them. I'm not sure if autoflake should fix it upstream, and/or if shed should reimplement is_python_file itself (or take it from isort/black/etc if they have one).

It seems odd that autoflake ignores .pyi files. Surely pyflakes and autoflake will run fine on type stubs.

Black also has a separate .pyi formatting mode, but I think the other wrapped tools are mostly just fine to operate on .pyi stubs too. Supporting this would be a new feature:

  • Add a new is_pyi: bool = False argument to the shed() function
  • Add .pyi to the known extensions in _should_format(), and define writer as a partial in this case , to pass is_pyi
  • Don't pass this further down to docstring formatting.
  • If is_pyi, pass the corresponding argument to black.Mode() and don't refactor even if passed refactor=True
  • In our readme, add pyi to the types_or list in our example pre-commit config

Closed by #61 ๐ŸŽ‰