Change `.style.yapf` precedence?
Opened this issue · 2 comments
Hello,
Thank you for this plugin. I have used it for years and I appreciate it greatly.
The PyYapf.sublime-settings
file's comments describe the "config"
parameter as:
// custom yapf style options
// if commented out then yapf will search for the formatting style in the following manner:
...
"config" : {...},
i.e., if "config"
exists, then yapf will NOT search for formatting styles...
I think PyYAPF should by default (or with a setting) first search for a .style.yapf
and only defer to the "config" : {...}
settings in PyYapf.sublime-settings
if a .style.yapf
does not exist.
I use PyYapf for all of my personal projects, but at work I committed a .style.yapf
in our codebase to keep the team in sync. In order for Sublime Text to respect this file, I had to comment out my PyYapf.sublime-settings
"config"
variable, which makes PyYapf not work on other projects (unless they also have a .style.yapf
file nearby)! That seems wrong to me.
If there is a way to configure PyYapf to respect .style.yapf
before PyYapf.sublime-settings
, please let me know, or otherwise please consider this a feature request (though I think it's a borderline bug).
Note I have the use_stdin
setting set to true
. When I comment out "config"
in the .sublime-settings
, PyYapf does successfully find my .style.yapf
. My issue is the precedence of different config sources. (Setting use_stdin
to false
does not fix this problem FYI.)
This issue discusses the relationship between use_stdin
and .style.yapf
, but I believe this is a separate matter.
I understand why PyYapf is the way it is - if there is no "config"
in .sublime-settings
, it lets Yapf search for the settings file(s). It's probably bad to re-implement searching for .style.yapf
and setup.cfg
since Yapf already does that.
One solution would be if YAPF had a --found-style-file
command that simply outputs whether or not YAPF can find a .style.yapf
or setup.cfg
to apply. It would mean PyYapf would have to run yapf --found-style-file
every time it runs, but this would presumably be fast and add negligible complexity.
Another solution would be if the PyYapf package explicitly supported per-project settings files. As far as I know, supporting project-specific settings is up to Package developers. Then I could add project-specific PyYapf.sublime-settings
to my project (and .gitignore
it) whenever I want PyYapf to defer to a .style.yapf
.