This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jack__d
Recipients RPecor, jack__d
Date 2021-07-28.03:12:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1627441953.65.0.339685440421.issue44752@roundup.psfhosted.org>
In-reply-to
Content
> Now that I see hasattr() uses getattr(), it looks like the tab completion issue might not stem from line 155, but from line 180 (https://github.com/python/cpython/blob/bb3e0c240bc60fe08d332ff5955d54197f79751c/Lib/rlcompleter.py#L180) where it calls getattr().

That is correct! I was able to fix the undesirable behavior by adding an early exit condition if we appear to have a property object. I checked for the existence of a property object like this:

    class Foo:

        @property
        def bar(self):
            return 'baz'

    def is_property(object, attr):
        return isinstance(getattr(type(object), attr, None), property)

    assert is_property(Foo(), 'bar')

The code that follows line 180 in the loop just checks if ``object.attribute`` is callable, and whether the callable takes arguments in order to determine whether to add parenthesis to the completion. In my opinion, we never really want to add parenthesis when providing completion for a property attribute anyway, so there's no reason to go through that code block if we are dealing with a property.

I opened a GitHub PR. Let me know what you think!
History
Date User Action Args
2021-07-28 03:12:33jack__dsetrecipients: + jack__d, RPecor
2021-07-28 03:12:33jack__dsetmessageid: <1627441953.65.0.339685440421.issue44752@roundup.psfhosted.org>
2021-07-28 03:12:33jack__dlinkissue44752 messages
2021-07-28 03:12:33jack__dcreate