Ask Your Question
1

yapf indent setting

asked 2022-07-14 19:05:01 -0600

bai's avatar

updated 2022-09-22 12:49:33 -0600

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.

edit retag flag offensive 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 -0600 )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 -0600 )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 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2022-09-22 12:49:21 -0600

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.

edit flag offensive delete link more
0

answered 2022-07-15 08:39:36 -0600

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.

edit flag offensive delete link more

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 -0600 )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 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2022-07-14 19:05:01 -0600

Seen: 110 times

Last updated: Sep 22