First time here? Check out the FAQ!
1

yapf indent setting
 

I use wingpro yapf to format files, but the indent of yapf is always 4 spaces.

My project folder has a yapf config file and I must use 2 spaces indent setting, I try to use yapf in the command line, it works well. So I use os command named yapf to finish the job, but I hope interal yapf support can read the config file and use indent correctly.

I use wing pro v7. I am not sure if v8 fix the problem.

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
bai's avatar
83
bai
asked 2 years ago
Wingware Support's avatar
4.2k
Wingware Support
updated 2 years ago

Comments

I have a similar problem (want to use tabs vs spaces) and as mentioned in comments, it might be enough to know where the yapf command is run from since for my needs I don't want to put config file in each folder of my project rather I am using the pyproject.toml file which "pyproject.toml located in the working directory from which YAPF is invoked." Placing this file in the project root directory doesn't seem to work.

Max Slimmer's avatar Max Slimmer (2 years ago)

Indeed, unfortunately according to the docs yapf looks up the directory tree in a sensible way for .style.yapf but does not do that for pyproject.toml. That's an unfortunate design and so indeed the fix going into Wing 9.0.0.2 isn't going to address this use case. We'll need to add an option to control invocation directory. I'll post again here when that is done.

Wingware Support's avatar Wingware Support (2 years ago)

Wing Pro 9.0.0.6 will have the ability to set the directory where reformatters are run, both in Project Properties and Preferences. Should be out in a few days.

Wingware Support's avatar Wingware Support (2 years ago)
see more comments

2 Answers

0

It looks like we're not sending --style arguments to the command that we run for our internal formatting support, so it's always using the default 'pep8' style. How are you specifying the style in the command line you're using in OS Commands? I want to see if we can expand this so it's possible to support your use case.

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
Wingware Support's avatar
4.2k
Wingware Support
answered 2 years ago
link

Comments

I didn't use style argument, only execute "yapf" command in the project directory. I have a .style.yapf to controll the style.

I hope wing pro will recognize the style file or use style argument to use yapf better.

bai's avatar bai (2 years ago)

Ah, I think the issue here is that we're not running yapf in the right directory. Is the .style.yapf in the same directory as the file being reformatted, or in the directory from which you start yapf?

Wingware Support's avatar Wingware Support (2 years ago)
see more comments
0

There's a fix going into Wing 9.0.0.2+ that should solve this by running yapf and other reformatters in the directory of the file being reformatted, so that configuration files like .stype.yapf will be found. This fix should be released within a couple of weeks.

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
Wingware Support's avatar
4.2k
Wingware Support
answered 2 years ago
link

Comments

see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)