'Visual Studio Code doesn't show the methods from an object in an array python

I'm learning oop in python after learning it in Java. It happens that i'm trying to create an array from my class Person which will contain Person objects within. When I create a single object Intellisense shows the methods available:

class Person:
  name: str
  
  def set_name(self, name: str):
      self.name = name
      
  
  person1 = Person()
  person1.set_name("John") #<--- Here it shows the custom method i made.

But when I make an array with Person objects within it and I try to use the methods calling the object from the array the methods just doesn't appear.

class Person:
  name: str
  
  def set_name(self, name: str):
      self.name = name
      
  people = []

  for i in range (5):
      people.append(Person())

  people[0].set_name("John") #<---- After writting the dot the methods are empty,
  #and when written it doesn't have the "color code" it should have.

Does anyone know why is this happening? :C



Solution 1:[1]

You can add type hint for people.

class Person:
  name: str
  
  def set_name(self, name: str):
      self.name = name
      
people = []

for i in range (5):
    people.append(Person())

people:list[Person] # add type hint here
people[0].set_name("John") 

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 YYLIZH