YAPF looks for certain configuration files containing user preferences regarding coding formatting. I have these configuration files in two places: ~/.config/yapf/style and a .style.yapf file in my project directory. However, when I run Atom Beautify in a Python file, using YAPF as my default formatting engine, it seems to ignore these files. I tried to setup YAPF from Atom Beautify settings page from inside Atom, but it only has settings for autopep8, apparently.
Here's my debug info. I configured YAPF to only break lines with more than 150 characters, but it is stilll breaking lines with ore than 79 characters, as it is its default.
Atom Beautify has its own configuration system in order to be ubiquitous given that it supports a great many beautifiers for a plurality of languages. A specific particular configuration system, such as this or a .toolrc file, would be an enhancement.
I understand. My particular problem was that autopep8 does not format function annotations correctly but, when I changed to YAPF, I wasn't able to configure it like I did autopep8 when using Atom Beaufity. Using yapf independently of the plugin, however, works correctly.
@Glavin001 Does https://github.com/Glavin001/atom-beautify/pull/671 address this issue or is it related?
Currently it looks like there are no options officially supported by YAPF: https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/yapf.coffee#L13
Here's the YAPF formatting stlye: https://github.com/google/yapf#formatting-style
Looks like we could use something similar to Uncrustify beautifier using cfg.coffee to generate a style file and pass it to yapf. See https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/uncrustify/index.coffee#L30-L33 and https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/uncrustify/index.coffee#L74 for example.
So the user would configure YAPF behavior through Atom Beautify and it would generate the configuration file for YAPF to read, nice. There are also some options that are common to both YAPF and autopep8, so they could be configured together.
Here is a list of all the other options an YAPF configuration file accepts and here is an example file from my own project, since I did not find any other complete examples out there.
Is this supposed to work now? Im an atom newb, just installed 1.11.2 with atom-beautify and set it to use yapf for python
"*":
"atom-beautify":
general:
analytics: false
python:
default_beautifier: "yapf"
indent_size: 2
max_line_length: 132
sort_imports: true
I have a config file for yapf (~/.config/yapf/style):
based_on_style = pep8
allow_multiline_lambdas=true
blank_line_before_nested_class_or_def=true
coalesce_brackets=true
column_limit=132
continuation_indent_width=4
dedent_closing_brackets=true
indent_width=2
spaces_before_comment=2
space_between_ending_comma_and_closing_bracket=true
split_arguments_when_comma_terminated=true
split_before_first_argument=true
split_before_logical_operator=true
split_before_named_assigns=true
But even simple things are not reformatted when I run beautify (e.g. max line length exceeded). No errors on the console either.
You might want to checkout https://atom.io/packages/python-yapf
Works great for me.
@scubahub if you're having issues please provide your debugging information and we can try to help 馃槂 .
Please follow the issue template provided. More specifically, adding a link to the required
debug.mdGist which includes debugging information that answers our most commonly asked questions.
Thank you.
Any supported by yapf location of config file does not make any sense for atom-beautify. Console call yapf works as espected.
For example setup.cfg:
[yapf]
column_limit=100
atom-beautify works with default value 79.
atom-beautify: 0.30.5
atom: 1.19.1
Is there any chance that custom config file could be provided, or there could be an option to allow yapf to use the default config file it finds? This is a useful feature where the formatter will look for a config file in the directory of the file you are formatting. This way, different projects with different people can have different configuration settings.
Bumping again and pointing out that standard styles are most useful when on teams of people and you don't want to manually coordinate styles. .style.yapf files are standard across IDEs. Having Atom specific config file doesn't make any sense when trying to standardize across a team unless you expect everyone on the team to use Atom.
Most helpful comment
Bumping again and pointing out that standard styles are most useful when on teams of people and you don't want to manually coordinate styles.
.style.yapffiles are standard across IDEs. Having Atom specific config file doesn't make any sense when trying to standardize across a team unless you expect everyone on the team to use Atom.