Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip files no longer ignores from stdin #1771

Closed
jeffwillette opened this issue Jul 2, 2021 · 3 comments
Closed

skip files no longer ignores from stdin #1771

jeffwillette opened this issue Jul 2, 2021 · 3 comments
Labels
question Further information is requested

Comments

@jeffwillette
Copy link

I had previsouly filed an issue asking for help with ignoring __init__.py files #1632. Along the way, something changed and this command no longer ignores __init__.py files. The way the command is being run is as follows...

isort --skip __init__.py --filter-files - < ./__init__.py

It might seem a little bit strange to skip a file and then read it from stdin, but this happens because NeoVim + ALE (https://github.com/dense-analysis/ale) runs isort on every save and reads from the current vim buffer which usually has a filepath of something like /tmp/<random chars>/__init__.py. To the best of my knowledge, NeoVim and ALE have always read from stdin, so it is very unlikely that the behavior on that end has changed.

Has there been any change within some of the recent isort versions which might have changed this behavior?

@timothycrosley
Copy link
Member

Hi @jeffwillette,

I'm sorry for the confusion! However, as written, I cannot see how it could work on any version of isort or any command in general.

isort --skip __init__.py --filter-files - < ./__init__.py doesn't provide any identification of the filename being passed in. isort does provide a way to specify the filename when sorting via a stream that you should work:

isort --skip __init__.py --filter-files --filename __init__.py - < ./__init__.py

@timothycrosley timothycrosley added the question Further information is requested label Jul 4, 2021
@jeffwillette
Copy link
Author

jeffwillette commented Jul 5, 2021

that could potentially work with a pull request to the vim plugin. I tried running it on the shell and I got an exception that was raised. Is this exception expected? It seems like it should be handled gracefully instead of raising an exception...

Traceback (most recent call last):
  File "/home/jeff/.venv/env/bin/isort", line 8, in <module>
    sys.exit(main())
  File "/home/jeff/.venv/env/lib/python3.8/site-packages/isort/main.py", line 1101, in main
    api.sort_stream(
  File "/home/jeff/.venv/env/lib/python3.8/site-packages/isort/api.py", line 188, in sort_stream
    raise FileSkipSetting(content_source)
isort.exceptions.FileSkipSetting: __init__.py was skipped as it's listed in 'skip' setting or matches a glob in 'skip_glob' setting

@timothycrosley
Copy link
Member

@jeffwillette good call out! I've improved this behavior so the skip will be silent in 5.9.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants