Monday, 16 January 2023

VSCode Python autocomplete missing some methods from superclass

I'm trying to use autocomplete for the Python AppDaemon module. Autocomplete is showing some of the inherited methods from the superclass such as get_state(), but some methods are missing such as log() and get_entity(). This behavior is the same in VSCode and PyCharm community.

Autocomplete from superclass

Autocomplete method from superclasses superclass

Here's the skeleton of a class I'm writing, which inherits from hass.Hass

import hassapi as hass
class AutocompleteTest(hass.Hass):
def initialize(self):
    self.get

Here's the class it inherits from (github link)

class Hass(adbase.ADBase, adapi.ADAPI):

The methods I want autocomplete are in adapi.ADAPI (github link). Here's the method definitions from the class

class ADAPI:
  # This method shows in autocomplete
  @utils.sync_wrapper
  async def get_state(
    self,
    entity_id: str = None,
    attribute: str = None,
    default: Any = None,
    copy: bool = True,
    **kwargs: Optional[Any],
  ) -> Any:

  # This method does not show in autocomplete
  def log(self, msg, *args, **kwargs):

  # This method does not show in autocomplete
  def get_entity(self, entity: str, **kwargs: Optional[Any]) -> Entity:

Can anyone help me understand what's going on, and how to get autocomplete fully working?

If anyone wants to give this a go, my requirements file is below, then you can copy the class from above

hassapi
iso8601
requests


from VSCode Python autocomplete missing some methods from superclass

No comments:

Post a Comment