question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ipython tab completion causing side effects when reading descriptors

See original GitHub issue

I have a test class which, when tab completed from an interactive terminal, causes side effects. Test class and descriptor:

class TestDescr():

    def __get__(self, obj, objtype):
        print("Side effects!")
        return 1

    def __set(self, obj, value):
        raise AttributeError("Error, read only attribute")

class TestClass():
    td = TestDescr()

Below is a copy of an ipython interactive session: (tried on pip version and master version)

> python __main__.py
Python 3.6.1 |Anaconda custom (64-bit)| (default, Mar 22 2017, 20:11:04) [MSC v.1900 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 6.0.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: cd ../../
c:\projects\mban_fpga_eval_fw_test

In [2]: %run test_file.py

In [3]: tc = TestClass()

Side effects!
Side effects!
In [4]: tc.td

Just to explain, when I type: tc. and then press tab, Side effects! is then printed twice.

I have tried this with Ipython version 5.3 with no such issues:

> ipython
Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.

IPython 5.3.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: %run test_file.py
ERROR:root:File `'test_file.py'` not found.

In [2]: cd ..
c:\projects\mban_fpga_eval_fw_test

In [3]: %run test_file.py

In [4]: tc = TestClass()

In [5]: tc.td

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
wolkenarchitektcommented, Oct 10, 2017

Upgrading Jedi to 0.11 solved the problem for me

0reactions
MrMinocommented, Jun 20, 2022

This was fixed in jedi.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does tab auto-completion in Python REPL and Jupyter ...
<tab> , I assumed Juptyer would show auto completions abc, bce, cde among other hidden methods and not evaluate them. Printing the logging...
Read more >
Bug #470824 “spurious trailing space after tab completion”
> Using IPython 0.10, when I use tab completion after cd, IPython inserts an extra space at the end of the trailing /....
Read more >
8.x Series — IPython 8.7.0 documentation
So don't put side effects in your getitems . ... Fixed error raised when attempting to tab-complete an input string with consecutive periods...
Read more >
Chapter 1. IPython: Beyond Normal Python
My answer sometimes … - Selection from Python Data Science Handbook [Book] ... Tab completion is also useful when importing objects from packages....
Read more >
Issues closed in the 2.x development cycle
#7272: qtconsole problems with pygments; #7049: Cause TypeError: 'NoneType' object is not callable in qtconsole; #6877: Qt console doesn't work with pygments ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found