Files not autoformatted on save when other options that work on save are set
See original GitHub issueDescription
What steps will reproduce the problem?
-
Turn on auto-format on save on, with black enabled. (haven’t tested with autopep8)
-
create a new file, input poorly formatted code such as
a = [3, 4]
-
press save.
-
inspect file in external editor to see it has not been formatted.
-
In spyder, press CTRL+ALT+I to format the file. You get the expected
a = [3, 4]
formatting. This proves black is working and spyder knows how to invoke it correctly.
Also, if you put several blank lines at the end of the file, when I press save the lines are correctly deleted, proving that format during save works in general (I have the check box for removing extra lines on save checked)
Versions
- Spyder version: 5.3.0
- Python version: 3.8.8
- Qt version: 5.12.10
- PyQt5 version: 5.12.3
- Operating System: Windows 7
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)
cookiecutter >=1.6.0 : 1.7.3 (OK)
diff_match_patch >=20181111 : 20200713 (OK)
intervaltree >=3.0.2 : 3.1.0 (OK)
IPython >=7.31.1;<8.0.0 : 7.32.0 (OK)
jedi >=0.17.2;<0.19.0 : 0.17.2 (OK)
jellyfish >=0.7 : 0.9.0 (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.9.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.1 (OK)
pylint >=2.5.0 : 2.7.4 (OK)
pyls_spyder >=0.4.0 : 0.4.0 (OK)
pylsp >=1.4.1;<1.5.0 : 1.4.1 (OK)
pylsp_black >=1.2.0 : 1.2.1 (OK)
qdarkstyle >=3.0.2;<3.1.0 : 3.0.3 (OK)
qstylizer >=0.1.10 : 0.2.1 (OK)
qtawesome >=1.0.2 : 1.0.2 (OK)
qtconsole >=5.3.0;<5.4.0 : 5.3.0 (OK)
qtpy >=2.0.1 : 2.0.1 (OK)
rtree >=0.9.7 : 0.9.7 (OK)
setuptools >=49.6.0 : 52.0.0.post20210125 (OK)
sphinx >=0.6.6 : 4.0.1 (OK)
spyder_kernels >=2.3.0;<2.4.0 : 2.3.0 (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 : 22.3.0 (OK)
# Optional:
cython >=0.21 : 0.29.23 (OK)
matplotlib >=3.0.0 : 3.3.4 (OK)
numpy >=1.7 : 1.20.1 (OK)
pandas >=1.1.1 : 1.2.4 (OK)
scipy >=0.17.0 : 1.6.2 (OK)
sympy >=0.7.3 : 1.8 (OK)
Issue Analytics
- State:
- Created a year ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
VSCode - Disable ALL Auto Formatting on Save
The ideal solution to this would just be to use the "Save without Formatting" command. This can be executed by either: ... This...
Read more >Format on Save (prettier) stopped working with latest update
I set prettier as the Default Formatter in Settings and it started working again. My Default Formatter was null. In case anyone is...
Read more >Automatically Format Code On File Save in Visual Studio ...
To automatically format the file on save, In Visual Studio Code, press Control + Shift + P or Command + Shift + P...
Read more >VSCode Format On Save – everything you need to know
Enable/Disable Format On Save · Open up VSCode Command Palette by pressing Ctrl + Shift + P. · Search and select Open Settings...
Read more >Prettier + Format On Save = Never worry about ... - Scott Sauber
Search for Format On Save and check the box. formatOnSave. Overriding Prettier settings. By default Prettier uses 2 spaces for your tab width ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@dalthviz, please take care of this one. The options @juliangilbey is referring to are these ones:
I think the solution for this would be to disable those options in the interface when
Autoformat on save
is on, add tooltip to them when that’s the case to explain why they are disabled, and don’t use them in our code because autoformatting takes care of all that.Thanks for the additional details @juliangilbey! I can reproduce this bug now.
We’ll try to fix it on our next version (5.3.1), to be released in mid May.