spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.33k stars 1.61k forks source link

Missing `yapf` for code formatting #14881

Open zhanggy2004 opened 3 years ago

zhanggy2004 commented 3 years ago

Thanks for adding code formatter to Spyder. I ran into some trouble in using yapf as the formatting provider and am looking forward to hearing your reply. Spyder is installed using conda on Windows 10.

Problem Description

In Spyder -> Tools -> Preferences -> Completion and linting -> Code style and formatting -> Code formatting -> Choose the code formatting provider, I can see autopep8 and black, but not yapf.

I have checked that yapf (0.30.0) and pyls-spyder (0.3.2) are installed.

image

What steps reproduce the problem?

  1. Open Spyder.
  2. Go to the above Preference page.

Versions

Dependencies

Mandatory:

atomicwrites >=1.2.0 : 1.4.0 (OK) chardet >=2.0.0 : 4.0.0 (OK) cloudpickle >=0.5.0 : 1.6.0 (OK) diff_match_patch >=20181111 : 20200713 (OK) intervaltree >=3.0.2 : 3.1.0 (OK) IPython >=7.6.0 : 7.21.0 (OK) jedi =0.17.2 : 0.17.2 (OK) jsonschema >=3.2.0 : 3.2.0 (OK) keyring >=17.0.0 : 22.3.0 (OK) nbconvert >=4.0 : 6.0.7 (OK) numpydoc >=0.6.0 : 1.1.0 (OK) paramiko >=2.4.0 : 2.7.2 (OK) parso =0.7.0 : 0.7.0 (OK) pexpect >=4.4.0 : 4.8.0 (OK) pickleshare >=0.4 : 0.7.5 (OK) psutil >=5.3 : 5.8.0 (OK) pygments >=2.0 : 2.8.0 (OK) pylint >=1.0 : 2.7.2 (OK) pyls >=0.36.2;<1.0.0 : 0.36.2 (OK) pyls_black >=0.4.6 : 0.4.6 (OK) pyls_spyder >=0.3.0 : 0.3.2 (OK) qdarkstyle >=2.8 : 2.8.1 (OK) qtawesome >=0.5.7 : 1.0.1 (OK) qtconsole >=5.0.1 : 5.0.2 (OK) qtpy >=1.5.0 : 1.9.0 (OK) rtree >=0.8.3 : 0.9.4 (OK) setuptools >=39.0.0 : 52.0.0.post20210125 (OK) sphinx >=0.6.6 : 3.5.1 (OK) spyder_kernels >=1.10.1;<1.11.0 : 1.10.2 (OK) textdistance >=4.2.0 : 4.2.1 (OK) three_merge >=0.1.1 : 0.1.1 (OK) watchdog >=0.10.3 : 1.0.2 (OK) zmq >=17 : 20.0.0 (OK)

Optional:

cython >=0.21 : 0.29.22 (OK) matplotlib >=2.0.0 : 3.3.4 (OK) numpy >=1.7 : 1.19.2 (OK) pandas >=1.1.1 : 1.2.3 (OK) scipy >=0.17.0 : 1.6.1 (OK) sympy >=0.7.3 : 1.7.1 (OK)

ccordoba12 commented 3 years ago

Hey @zhanggy2004, thanks for reporting. We haven't included Yapf as a formatter yet because right now there's no way change to change the maximum allowed length in Yapf through the Python language server. So that would make the option just below the dropdown you showed above to be inconsistent.

We plan to do that in the coming months. Thanks for your patience.

01tot10 commented 2 years ago

Hey all! Just wanted to give +1 for this enhancement. Was trying to enable yapf as a formatter today, but faced the same problem as OP. Looking forward to having yapf integrated within Spyder!

@ccordoba12 Is the plan also to respect user defined styles for the formatting, as provided via .style.yapf or similar?

ccordoba12 commented 2 years ago

Yeah, that's the idea. We'll try to do this in the next months.