Issue Report Checklist
Problem Description
What steps reproduce the problem?
- outline not listing functions, doesn’t matter if they are in code cells or not

- outline listing module imports as generic functions when they are moved to a new line with ""

What is the expected output? What do you see instead?
Paste Traceback/Error Below (if applicable)
PASTE TRACEBACK HERE
Versions
- Spyder version: 5.1.3
- Python version: 3.7.11
- Qt version: 5.9.7
- PyQt version: 5.9.2
- Operating System name/version: windows 10
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.2 (OK)
diff_match_patch >=20181111 : 20200713 (OK)
intervaltree >=3.0.2 : 3.1.0 (OK)
IPython >=7.6.0 : 7.26.0 (OK)
jedi >=0.17.2;<0.19.0 : 0.17.2 (OK)
jsonschema >=3.2.0 : 3.2.0 (OK)
keyring >=17.0.0 : 23.0.1 (OK)
nbconvert >=4.0 : 6.1.0 (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.10.0 (OK)
pylint >=2.5.0;<2.10.0 : 2.9.6 (OK)
pyls_spyder >=0.4.0 : 0.4.0 (OK)
pylsp >=1.2.2;<1.3.0 : 1.2.2 (OK)
pylsp_black >=1.0.0 : None (OK)
qdarkstyle =3.0.2 : 3.0.2 (OK)
qstylizer >=0.1.10 : 0.1.10 (OK)
qtawesome >=1.0.2 : 1.0.2 (OK)
qtconsole >=5.1.0 : 5.1.0 (OK)
qtpy >=1.5.0 : 1.10.0 (OK)
rtree >=0.9.7 : 0.9.7 (OK)
setuptools >=49.6.0 : 52.0.0.post20210125 (OK)
sphinx >=0.6.6 : 4.0.2 (OK)
spyder_kernels >=2.1.1;<2.2.0 : 2.1.1 (OK)
textdistance >=4.2.0 : 4.2.1 (OK)
three_merge >=0.1.1 : 0.1.1 (OK)
watchdog >=0.10.3 : 2.1.3 (OK)
zmq >=17 : 22.2.1 (OK)
# Optional:
cython >=0.21 : None (OK)
matplotlib >=2.0.0 : 3.4.2 (OK)
numpy >=1.7 : 1.18.5 (OK)
pandas >=1.1.1 : 1.1.2 (OK)
scipy >=0.17.0 : 1.6.3 (OK)
sympy >=0.7.3 : None (OK)
A bit off topic here but just in short: The python import system considers each package (i.e. folder) that dies not contain a “init.py” file a “namespace package”. You don’t need that for standalone projects normally. It is only useful if you want to have multiple projects to be importable from the same namespace. This is the (lenghty but detailed) description of namespace packages: https://www.python.org/dev/peps/pep-0420/
Moritz Lürig @.***> schrieb am Mo., 13. Sep. 2021, 16:28:
I can confirm that this is the issue - adding an
__init__.pysolved it for meI have also encountered this problem with Spyder 5.2.2 on Windows 10.
Continuing discussion from comment on issue #15139 after some more testing.
Project directory structure (in summary)
Versions
Installed with .exe installer, same result with Spyder’s own Python 3.7.9 and the system-wide Python 3.9.2 which I mainly use.
Results
The outline view works for modules placed in the project root directory (e.g.
build_script.py), but not for anything undersrc/and further down (only filename is shown).Curiously, the outlines for
src/and its modules work and update even for new files after removing__init__.pyfromsrc/, changing the Python interpreter and restarting Spyder (?!)Workaround
Putting an
__init__.pyintosrc/and restarting Spyder (or the LSP language server) makes the outline work for all the modules insrc/and its subdirectories.I didn’t think about doing it at first, given that
src/is just my folder for keeping code and is not intended to be a package. But happily it looks workable.@ccordoba12
Thanks for merging issues.
I also solved this issue by adding an init.py (sorry, I failed to input the right filename.)
I don’t have any of my packages installed in the python installation that spyder uses (since I’m using the installer, it is completely separate from any other installations on my system).
Great that you could reproduce the problem and thanks for taking it on!
I was able to reproduce the problem with @Brow71189’s example and will try to fix it in our next release. At least you have a workaround until then.