Spyder: Additional empty line is added at the end of the template

Created on 4 May 2020  Â·  4Comments  Â·  Source: spyder-ide/spyder

Issue Report Checklist

  • [x] Searched the issues page for similar reports
  • [x] Read the relevant sections of the Spyder Troubleshooting Guide and followed its advice
  • [x] Reproduced the issue after updating with conda update spyder (or pip, if not using Anaconda)
  • [ ] Could not reproduce inside jupyter qtconsole (if console-related)
  • [ ] Tried basic troubleshooting (if a bug/error)

    • [x] Restarted Spyder

    • [x] Reset preferences with spyder --reset

    • [ ] Reinstalled the latest version of Anaconda

    • [x] Tried the other applicable steps from the Troubleshooting Guide

  • [x] Completed the Problem Description, Steps to Reproduce and Version sections below

Problem Description

An empty line is added to the end of the template when opening a new file (Ctrl-N).

What steps reproduce the problem?

  1. Edit template for new files.
  2. Make a new file (Ctrl-N)

What is the expected output? What do you see instead?

My template ends with the following lines:

if __name__ == '__main__':
    pass

When I open a new file, I get the following:

if __name__ == '__main__':
    pass


Please note that there is an additional empty line at the end!

Versions

  • Spyder version: 4.1.2
  • Python version: 33.6.9 64-bit
  • Qt version: 5.12.7
  • PyQt version: 5.12.3
  • Operating System name/version: Linux Mint 19.3

Dependencies


# Mandatory:
atomicwrites >=1.2.0           :  1.3.0 (OK)
chardet >=2.0.0                :  3.0.4 (OK)
cloudpickle >=0.5.0            :  1.3.0 (OK)
diff_match_patch >=20181111    :  20181111 (OK)
intervaltree                   :  None (OK)
IPython >=4.0                  :  7.13.0 (OK)
jedi =0.15.2                   :  0.15.2 (OK)
keyring                        :  None (OK)
nbconvert >=4.0                :  5.6.1 (OK)
numpydoc >=0.6.0               :  0.9.2 (OK)
parso =0.5.2                   :  0.5.2 (OK)
pexpect >=4.4.0                :  4.8.0 (OK)
pickleshare >=0.4              :  0.7.5 (OK)
psutil >=5.3                   :  5.7.0 (OK)
pygments >=2.0                 :  2.6.1 (OK)
pylint >=0.25                  :  2.4.4 (OK)
pyls >=0.31.9;<0.32.0          :  0.31.9 (OK)
qdarkstyle >=2.8               :  2.8 (OK)
qtawesome >=0.5.7              :  0.7.0 (OK)
qtconsole >=4.6.0              :  4.7.1 (OK)
qtpy >=1.5.0                   :  1.9.0 (OK)
sphinx >=0.6.6                 :  2.4.4 (OK)
spyder_kernels >=1.9.0;<1.10.0 :  1.9.0 (OK)
watchdog                       :  None (OK)
xdg >=0.26                     :  0.26 (OK)
zmq >=17                       :  19.0.0 (OK)

# Optional:
cython >=0.21                  :  None (OK)
matplotlib >=2.0.0             :  None (OK)
numpy >=1.7                    :  1.18.2 (OK)
pandas >=0.13.1                :  None (OK)
scipy >=0.17.0                 :  1.4.1 (OK)
sympy >=0.7.3                  :  None (OK)
Editor Bug

All 4 comments

@sphh thanks for the report. Seems like a minor nuisance but indeed something not desired.

Since most style guides expect an empty line at the end, your template could omit this empty line in the meantime.

We will address this in a future release.

Cheers

Yes, it is a nuisance and I hope easy to fix.

And yes, I already considered removing the final empty line in the template as a temporary workaround …

Thanks @juanis2112 (and @goanpeca and @ccordoba12) for taking care of this and solving it that quickly!!

I applied the patch in my installation and can confirm that it works as expected.

Glad to hear it works as expected @sphh 😄 !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ok97465 picture ok97465  Â·  3Comments

spyder-bot picture spyder-bot  Â·  3Comments

yogu220172 picture yogu220172  Â·  3Comments

gabrielclow picture gabrielclow  Â·  3Comments

spyder-bot picture spyder-bot  Â·  3Comments