You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Intellisense doesn't work for a Class Instance returned from another Class Instance #647
VS Code version: 1.19.3
Python Extension version: 0.9.1
Python Version: 3.5.1
OS and version: macOS 10.13.1
Actual behavior
I have an object called Game which contains a dictionary of two Team objects. The Game class has a method which returns a Tuple of these two teams based on one of their attributes.
Accessing the Team objects directly from the variable name that instantiated it allows for Intellisense to work correctly, but when I assign new values based on the return value of the function method above, Intellisense does not provide a list of attributes for those objects.
Expected behavior
I would expect that a variable that references an instance of an Object also return the attributes related to that object.
This is the method that returns the Team objects from the Game object -
Logs
Output from Python output panel No logs in output panel.
Output from Console window (Help->Developer Tools menu) No error logs in Console window.
Output from Terminal, showing memory addresses of referenced objects.
$ /usr/local/bin/python3 /Users/mattdonders/Development/python/devils-goal-twitter/scratchpad/oop-checkGameStatus.py --console --notweets
Preferred Team - <NHLGameEvents.Team object at 0x10410fba8>
Other Team - <NHLGameEvents.Team object at 0x1041f5438>
** Game Attributes **
<NHLGameEvents.Game object at 0x104217390>
teams: {'away': <NHLGameEvents.Team object at 0x10410fba8>, 'home': <NHLGameEvents.Team object at 0x1041f5438>}
** Home Team Attributes **
<NHLGameEvents.Team object at 0x1041f5438>
preferred: False
** Away Team Attributes **
<NHLGameEvents.Team object at 0x10410fba8>
preferred: True
Worked on this code last night and it seems that this happens for instances of objects passed into a class that are not set within the __init__ of the object.
For example, if I create a new instance of another Object within __init__ I can reference that object and Intellisense works just fine, but if I have self.object = None or self.objects = [] within the __init__ then Intellisense isn't aware of the object type.
For example, changing my code to the below, allows me to reference game.home_team.<attribute> from anywhere in my code where previously game.teams["home"].<attribute> wouldn't work. The other thing as mentioned above is that since I create a new Period() and Shootout() instance within my Game object creation, I can reference those by game.period.<attribute> with Intellisense working just fine. I assume this is because Intellisense knows exactly what type of object this is.
class Game(object):
"""Holds all game related attributes - usually one instance created per game."""
def __init__(self, game_type, date_time, game_state, venue,
home, away, preferred, live_feed):
self.game_type = game_type
self.date_time = date_time
self.game_state = game_state
self.venue = venue
self._live_feed = live_feed
self.home_team = home
self.away_team = away
# Not passed in at object creation time
if preferred == "home":
self.preferred_team = home
self.other_team = away
else:
self.preferred_team = away
self.other_team = home
self.shootout = Shootout()
self.period = Period()
Because it has been more than a month since we requested more info, I'm closing this issue. If you are able to provide the info later then please do so and we can re-open the issue.
I am also experiencing this.
I have one module A with a class in it B, and a regular method C
B has both static and regular methods
In module D, I have a class E.
In E, I have attempted to reference an instance of B, and method C is not appearing in Intellisense.
Class E is referencing a collection of class B from module A, in a for loop within method F.
A = tidal
B = Jobdep
C = getVarCondition()
D = autosys
E = Job
F = getConditions()
Line 297 with jdrow - instance of B - Jobdep will not show name in list
Notice the static methods appeared, not the regular class instance one getVarCondition() or C....
Python 3.6.5 on Windows 2012RC2 64 bit.
I found the root of the problem for my case! An indentation issue!!!
Compare this change:
That change threw out quite a few errors in lint.
I subsequently changed the triple quoted string to comments too.
Activity
mattdonders commentedon Jan 31, 2018
Worked on this code last night and it seems that this happens for instances of objects passed into a class that are not set within the
__init__of the object.For example, if I create a new instance of another Object within
__init__I can reference that object and Intellisense works just fine, but if I haveself.object = Noneorself.objects = []within the__init__then Intellisense isn't aware of the object type.For example, changing my code to the below, allows me to reference
game.home_team.<attribute>from anywhere in my code where previouslygame.teams["home"].<attribute>wouldn't work. The other thing as mentioned above is that since I create a newPeriod()andShootout()instance within my Game object creation, I can reference those bygame.period.<attribute>with Intellisense working just fine. I assume this is because Intellisense knows exactly what type of object this is.DonJayamanne commentedon Feb 12, 2018
Matt Donders (@mattdonders)
Please could you provide a code sample (or a repo) that we could use to replicate this issue.
brettcannon commentedon Apr 2, 2018
Because it has been more than a month since we requested more info, I'm closing this issue. If you are able to provide the info later then please do so and we can re-open the issue.
jgfet commentedon Jun 8, 2018
I am also experiencing this.
I have one module A with a class in it B, and a regular method C
B has both static and regular methods
In module D, I have a class E.
In E, I have attempted to reference an instance of B, and method C is not appearing in Intellisense.
Class E is referencing a collection of class B from module A, in a for loop within method F.
Line 297 with jdrow - instance of B - Jobdep will not show name in list


Notice the static methods appeared, not the regular class instance one getVarCondition() or C....

Python 3.6.5 on Windows 2012RC2 64 bit.I found the root of the problem for my case! An indentation issue!!!

Compare this change:
That change threw out quite a few errors in lint.
I subsequently changed the triple quoted string to comments too.