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

YAPF configuration files are ignored #786

Closed
douglasrizzo opened this issue Feb 6, 2016 · 12 comments · Fixed by #856
Closed

YAPF configuration files are ignored #786

douglasrizzo opened this issue Feb 6, 2016 · 12 comments · Fixed by #856

Comments

@douglasrizzo
Copy link

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.

@prettydiff
Copy link
Collaborator

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.

@douglasrizzo
Copy link
Author

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.

@prettydiff
Copy link
Collaborator

@Glavin001 Does #671 address this issue or is it related?

@Glavin001
Copy link
Owner

#671 fixes a bug, #669, in the YAPF beautifier within Atom Beautify caused by the return code from yapf being unexpected and Atom Beautify thinking it was an error return code, therefore throwing an error instead of beautifying.

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.

@douglasrizzo
Copy link
Author

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.

@scubahub
Copy link

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.

@coreybrett
Copy link

You might want to checkout https://atom.io/packages/python-yapf
Works great for me.

@Glavin001
Copy link
Owner

@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.md Gist which includes debugging information that answers our most commonly asked questions.
Thank you.

@andryushka
Copy link

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

@zach-nervana
Copy link

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.

@zach-nervana
Copy link

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.

@01tot10
Copy link

01tot10 commented Jun 29, 2022

Hey! I'm a little confused with the state of this feature. I tried using yapf within Atom today, but it seems to ignore the .style.yapf file within my project folder. The pull request #856 is marked to have resolved the issue, but since there are some comments afterwards stating the opposite, I don't know what I should be expecting?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants