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.

bai's avatar
73
bai
asked 2022-07-14 19:05:01 -0500
Wingware Support's avatar
4.1k
Wingware Support
updated 2022-09-22 12:49:33 -0500
edit flag offensive 0 remove flag close merge delete

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 (2022-09-27 17:16:09 -0500) edit

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 (2022-09-28 08:38:24 -0500) edit

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 (2022-11-02 09:39:33 -0500) edit
add a comment 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.

Wingware Support's avatar
4.1k
Wingware Support
answered 2022-07-15 08:39:36 -0500
edit flag offensive 0 remove flag delete 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 (2022-07-21 18:38:09 -0500) edit

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 (2022-07-22 08:28:18 -0500) edit
add a comment 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.

Wingware Support's avatar
4.1k
Wingware Support
answered 2022-09-22 12:49:21 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment 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