Autosuggest Missing when Subclassing Non-Constant

When creating a subclass, I normally receive prompts suggesting methods to override.  For example, if I have a superclass with a method "foo", then if I create a subclass and type "def f" I normally see a suggestion for "foo" along with its function signature, etc.

However, when I subclass using a dynamic reference to the superclass, these suggestions disappear, even when I have statically given an upper bound on the referent. 

For example:

The return value of "dynamic()" is stated to by a subclass of "Foo".  This means that I expect to see a suggestion for the "foo" method - but it is missing, just as if I had subclassed a variable with no type hints at all.

Is there a way to fix this using annotations/type hints (preferably only on "dynamic()", but I'll take what I can get), or is this a limitation of PyCharm?

2 comments
Comment actions Permalink

In this particular case it's IDE limitation, we don't look inside dynamic() function as it may be a lot more complex. Feel free to submit a feature request to our issue tracker https://youtrack.jetbrains.com/issues

1
Comment actions Permalink

Thanks for the fast response.  It's good to know how the editor works.  

As a sort-of fix, I am using an idiom where every time I subclass `dynamic()` I subclass `Foo` as well, which leads to the desired behavior despite being a bit odd to look at.  

Thanks!

0

Please sign in to leave a comment.