spyder-ide / spyder

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

Autocomplete showing global namespace (including yet not allocated variables). #10681

Open mluerig opened 5 years ago

mluerig commented 5 years ago

(I am not sure how to make a reproducible example for this case, my apologies).

Problem Description

Code completion (after the dot) shows all classes and methods in the namespace, even if they have not been allocated yet. e.g.

What steps reproduce the problem?

I invoke a class from a module that I have installed with pip development mode.

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

Autocomplete only the parameters that have been allocated / called.

Versions

Dependencies

IPython >=4.0     :  7.5.0 (OK)
cython >=0.21     :  None (NOK)
jedi >=0.9.0      :  0.15.1 (OK)
matplotlib >=2.0.0:  3.1.1 (OK)
nbconvert >=4.0   :  5.6.1 (OK)
numpy >=1.7       :  1.17.4 (OK)
pandas >=0.13.1   :  0.25.3 (OK)
pycodestyle >=2.3 :  2.5.0 (OK)
pyflakes >=0.6.0  :  2.1.1 (OK)
pygments >=2.0    :  2.4.2 (OK)
pylint >=0.25     :  2.4.3 (OK)
qtconsole >=4.2.0 :  4.5.5 (OK)
rope >=0.9.4      :  0.14.0 (OK)
sphinx >=0.6.6    :  2.2.1 (OK)
sympy >=0.7.3     :  None (NOK)

packages in environment at C:\Anaconda3\envs\phenopype_env:

Name Version Build Channel alabaster 0.7.12 py37_0 asn1crypto 1.2.0 py37_0 astroid 2.3.2 py37_0 atomicwrites 1.3.0 pypi_0 pypi attrs 19.3.0 py_0 babel 2.7.0 py_0 backcall 0.1.0 py37_0 bleach 3.1.0 py37_0 ca-certificates 2019.10.16 0 certifi 2019.9.11 py37_0 cffi 1.13.1 py37h7a1dbc1_0 chardet 3.0.4 py37_1003 cloudpickle 1.2.2 py_0 colorama 0.4.1 py37_0 cryptography 2.8 py37h7a1dbc1_0 cycler 0.10.0 pypi_0 pypi decorator 4.4.1 py_0 defusedxml 0.6.0 py_0 docutils 0.15.2 py37_0 entrypoints 0.3 py37_0 exdir 0.4.1 pypi_0 pypi exifread 2.1.2 pypi_0 pypi icu 58.2 ha66f8fd_1 idna 2.8 py37_0 imagesize 1.1.0 py37_0 importlib_metadata 0.23 py37_0 ipykernel 5.1.3 py37h39e3cac_0 ipython 7.5.0 pypi_0 pypi ipython_genutils 0.2.0 py37_0 isort 4.3.21 py37_0 jedi 0.15.1 py37_0 jinja2 2.10.3 py_0 jpeg 9b hb83a4c4_2 jsonschema 3.1.1 py37_0 jupyter_client 5.3.4 py37_0 jupyter_core 4.6.1 py37_0 keyring 18.0.0 py37_0 kiwisolver 1.1.0 pypi_0 pypi lazy-object-proxy 1.4.3 py37he774522_0 libpng 1.6.37 h2a8f88b_0 libsodium 1.0.16 h9d3ae62_0 markupsafe 1.1.1 py37he774522_0 matplotlib 3.1.1 pypi_0 pypi mccabe 0.6.1 py37_1 mistune 0.8.4 py37he774522_0 more-itertools 7.2.0 py37_0 nbconvert 5.6.1 py37_0 nbformat 4.4.0 py37_0 numpy 1.17.4 pypi_0 pypi numpydoc 0.9.1 py_0 opencv-contrib-python 3.4.5.20 pypi_0 pypi openssl 1.1.1d he774522_3 packaging 19.2 py_0 pandas 0.25.3 pypi_0 pypi pandoc 2.2.3.2 0 pandocfilters 1.4.2 py37_1 parso 0.5.1 py_0 phenopype 0.9.0 dev_0 pickleshare 0.7.5 py37_0 pillow 6.2.1 pypi_0 pypi pip 19.3.1 py37_0 pluggy 0.13.0 pypi_0 pypi prompt_toolkit 2.0.10 py_0 psutil 5.6.3 py37he774522_0 py 1.8.0 pypi_0 pypi pycodestyle 2.5.0 py37_0 pycparser 2.19 py37_0 pyflakes 2.1.1 py37_0 pygments 2.4.2 py_0 pylint 2.4.3 py37_0 pyopenssl 19.0.0 py37_0 pyparsing 2.4.2 py_0 pyqt 5.9.2 py37h6538335_2 pyrsistent 0.15.4 py37he774522_0 pysocks 1.7.1 py37_0 pytesseract 0.2.6 pypi_0 pypi pytest 4.2.0 pypi_0 pypi python 3.7.5 h8c8aaf0_0 python-dateutil 2.8.1 py_0 pytz 2019.3 py_0 pywin32 223 py37hfa6e2cd_1 pyyaml 5.1.2 pypi_0 pypi pyzmq 18.1.0 py37ha925a31_0 qt 5.9.7 vc14h73c81de_0 qtawesome 0.6.0 py_0 qtconsole 4.5.5 py_0 qtpy 1.9.0 py_0 requests 2.22.0 py37_0 rope 0.14.0 py_0 ruamel-yaml 0.16.5 pypi_0 pypi ruamel-yaml-clib 0.2.0 pypi_0 pypi scipy 1.3.2 pypi_0 pypi setuptools 41.6.0 py37_0 sip 4.19.8 py37h6538335_0 six 1.12.0 py37_0 snowballstemmer 2.0.0 py_0 sphinx 2.2.1 py_0 sphinxcontrib-applehelp 1.0.1 py_0 sphinxcontrib-devhelp 1.0.1 py_0 sphinxcontrib-htmlhelp 1.0.2 py_0 sphinxcontrib-jsmath 1.0.1 py_0 sphinxcontrib-qthelp 1.0.2 py_0 sphinxcontrib-serializinghtml 1.1.3 py_0 spyder 3.3.6 py37_0 spyder-kernels 0.5.2 py37_0 sqlite 3.30.1 he774522_0 testpath 0.4.2 py37_0 tornado 6.0.3 py37he774522_0 trackpy 0.4.1 pypi_0 pypi traitlets 4.3.3 py37_0 urllib3 1.24.2 py37_0 vc 14.1 h0510ff6_4 vs2015_runtime 14.16.27012 hf0eaf9b_0 wcwidth 0.1.7 py37_0 webencodings 0.5.1 py37_1 wheel 0.33.6 py37_0 win_inet_pton 1.1.0 py37_0 wincertstore 0.2 py37_0 wrapt 1.11.2 py37he774522_0 zeromq 4.3.1 h33f27b4_3 zipp 0.6.0 py_0 zlib 1.2.11 h62dcd97_3

goanpeca commented 5 years ago

@mluerig could you add a screenshot of what you mean? Thanks!

mluerig commented 5 years ago

image

e.g. create_templateis a method - fine. but colour_maskis an array that has not yet been created, but can be created with create_template. shouldn't be visible

ccordoba12 commented 5 years ago

@mluerig, thanks for reporting. Please post a code sample that generates this error so we can take a look at it in our side.

mluerig commented 5 years ago

in retrospect, I'm not sure if this is error or expected behavior. anyways, assume following module:

testmod\
    __init__.py
    base.py

base.py contains

class testClass:
    def __init__(self, arg1):
        self.arg1 = arg1

    def method1(self, mod):
        self.result = self.arg1 * mod

Now, when I do

import testmod
tm = testmod.base.testClass(arg1=50)
tm.

tm. already shows result, although it has not yet been "created" through method1. would it make sense to be able to hide this?

In general, during development, I am assuming that my users will use spyder. Being able to see or control what is visible in autocomplete would be nice.

ccordoba12 commented 4 years ago

@mluerig, thanks! Could you upload the contents of testmod in a zip file so we don't have to recreate ourselves?

mluerig commented 4 years ago

testmod.zip