except while saving file with black enabled
See original GitHub issueDescription
What steps will reproduce the problem?
I think this is due to black - when I hit save I often get this exception when I have auto formatting with black on save enabled. This happens both when I just press save button, or use CTRL+ALT+I to auto format the file.
Traceback
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\spyder\plugins\editor\widgets\editor.py", line 1926, in _save_file
self.modification_changed(index=index)
File "C:\Anaconda3\lib\site-packages\spyder\plugins\editor\widgets\editor.py", line 2382, in modification_changed
finfo = self.data[index]
IndexError: list index out of range
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\spyder\plugins\editor\widgets\editor.py", line 1926, in _save_file
self.modification_changed(index=index)
File "C:\Anaconda3\lib\site-packages\spyder\plugins\editor\widgets\editor.py", line 2382, in modification_changed
finfo = self.data[index]
IndexError: list index out of range
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\spyder\plugins\editor\widgets\editor.py", line 1926, in _save_file
self.modification_changed(index=index)
File "C:\Anaconda3\lib\site-packages\spyder\plugins\editor\widgets\editor.py", line 2382, in modification_changed
finfo = self.data[index]
IndexError: list index out of range
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\spyder\plugins\editor\widgets\editor.py", line 1926, in _save_file
self.modification_changed(index=index)
File "C:\Anaconda3\lib\site-packages\spyder\plugins\editor\widgets\editor.py", line 2382, in modification_changed
finfo = self.data[index]
IndexError: list index out of range
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:5 (3 by maintainers)
Top Results From Across the Web
Error message in Office when a file is blocked by registry ...
In the Trust Center window, select File Block Settings, and then clear the "Open" or "Save" check box for the file type that...
Read more >Black --exclude argument not excluding desired file(s)
Let's say I have the following python file ...
Read more >VSCode: Using Black to automatically format Python
Black is "the uncompromising Python code formatter." It can be configured to automatically format your code whenever you save a file in VSCode....
Read more >How to Enable Excel Dark Mode? 2 Easy Methods
Step 1: Enable the Dark Mode in the Office Theme That is, go to the Office Theme section under Files > Options and...
Read more >How to format files on save using black with neovim and coc
3 Answers 3 · Use "coc.preferences.formatOnType": true to enable format on type feature. · Use "coc.preferences. · Use :call CocAction('format') to ...
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
Thanks @rlabbe for reporting this problem again! That gave me the motivation to see how to reproduce it and I finally did it.
This starts to happen as soon as you reorganize tabs in the editor. Since we’re using the tab index to perform some operations after auto-formatting, and that index is borked with the tab movement, this error keeps showing up after that.
I’ll post more details on issue #14639 so that @dalthviz can fix it.
Correction: This happens when a formatting options is taking place and you close some tabs in the editor. See https://github.com/spyder-ide/spyder/issues/14639#issuecomment-1104370362.