reorder-python-imports icon indicating copy to clipboard operation
reorder-python-imports copied to clipboard

Support for pyi files now types_or is implemented

Open Greedquest opened this issue 3 years ago • 3 comments

Further to #103 which was closed at the time.

Would it be possible to update the pre-commit hooks for this repo to allow it to run by default on pyi files?

Greedquest avatar May 18 '22 11:05 Greedquest

Or alternatively is there a way to avoid this in my local config:

hooks:
-   id: reorder-python-imports
    files: \.pyi?$
    types: []

... as using types_or e.g.:

hooks:
-   id: reorder-python-imports
    types_or: [python, pyi]

... doesn't seem to do anything in the .pre-commit-config.yaml. Does this setting only work for the hooks config, not the client side one?

Greedquest avatar May 21 '22 10:05 Greedquest

@Greedquest in your own config you'll also have to override types, e.g. I think this should work:

hooks:
-   id: reorder-python-imports
    types_or: [python, pyi]
    types: [text]  # overwrite types: [python]

MarcoGorelli avatar May 21 '22 16:05 MarcoGorelli

@MarcoGorelli Oh that's kind of crazy but makes sense I suppose, thanks! Is types: [text] the default value of types, equivalent to what happens when you don't specify it in the hooks config? (i.e. I understand we need to override it locally, presumably setting it back to the equivalent of what it would have been if it were never specified in the first place?)

Greedquest avatar May 24 '22 08:05 Greedquest