You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've faced a similar problem today where "Sort dependencies" would sometimes ignore the local isort configuration. Could it be that the working directory is sometimes incorrect when invoking external tools?
Don Jayamanne (@DonJayamanne) The problem is not with yapfArgs as it works correctly with the example provided above, the problem is that without overriding yapfArgs the tool does not always find the default config file which is in the root of the repository. The same thing happens in my isort example.
I've found a way to reproduce this. It turns out that when you run any of the formatters (yapf, isort etc.) on an unsaved file, they look for their config files outside of the current workspace directory.
This is because in unsaved case file is actually saved in temp folder and then formatted so formatter can't access style rules that are next to the actual file.
Would it be possible to save the temporary file next to the real one so that things just work without VSCode having to reimplement parts of the tool logic?
Yes. There a small risk that if something fails temp file will remain and appear in the workspace (and possibly the git changes). We could try and locate the file too.
Activity
DonJayamanne commentedon Feb 8, 2018
Please try using the following format:
patrys commentedon Feb 8, 2018
I've faced a similar problem today where "Sort dependencies" would sometimes ignore the local
isortconfiguration. Could it be that the working directory is sometimes incorrect when invoking external tools?patrys commentedon Feb 8, 2018
Don Jayamanne (@DonJayamanne) The problem is not with
yapfArgsas it works correctly with the example provided above, the problem is that without overridingyapfArgsthe tool does not always find the default config file which is in the root of the repository. The same thing happens in myisortexample.(Disclaimer: I work with Krzysztof Wolski (@krzysztofwolski).)
DonJayamanne commentedon Feb 8, 2018
Apologies, for the misunderstanding.
patrys commentedon Feb 13, 2018
I've found a way to reproduce this. It turns out that when you run any of the formatters (
yapf,isortetc.) on an unsaved file, they look for their config files outside of the current workspace directory.MikhailArkhipov commentedon Feb 20, 2018
This is because in unsaved case file is actually saved in temp folder and then formatted so formatter can't access style rules that are next to the actual file.
DonJayamanne commentedon Feb 20, 2018
I think we should look for the file, and then apply it.
We can walk up the folder structure and then use that file when formatting a temporary file.
patrys commentedon Feb 20, 2018
Would it be possible to save the temporary file next to the real one so that things just work without VSCode having to reimplement parts of the tool logic?
MikhailArkhipov commentedon Feb 20, 2018
Yes. There a small risk that if something fails temp file will remain and appear in the workspace (and possibly the git changes). We could try and locate the file too.
#730, #838 (#845)