Python static property autocomplete list not working in PyCharm
I'm using PyCharm Community Edition 2024.2.4. Autocomplete function lists appear correctly except in the case where I have a static property returning an object instance.
The static property syntax comes from this post: @staticmethod with @property
class staticproperty(property):
def __get__(self, owner_self, owner_cls):
return self.fget()
class _ScorecardClass(object):
_average = 0
@property
def average_score(self) -> float:
return self._average
@average_score.setter
def average_score(self, value):
self._average = value
class MainClass(object):
@staticmethod
def _get_scorecard():
return _ExternalDataProvider._get_scorecard()
@staticproperty
def Scorecard() -> _ScorecardClass:
r"""Returns the scorecard."""
return MainClass._get_scorecard()
In calling code, I can access the Scorecard object via its static property as follows:
MainClass.ScoreCard
However, the average_score property is not shown in the popup function list for ScoreCard. If I enter the function name manually, the code runs correctly.
average = MainClass.ScoreCard.average_score
I have the various code-completion options enabled in PyCharm. It seems to work fine for instance properties, but not statics. The auto-complete list displays correctly in VS Code. I have tried Python 3.9 and 3.12 and it's the same in both cases.
If I do:
sc: _ScorecardClass
The sc variable shows the various properties of _ScorecardClass in its autocomplete list, complete with docstring when the property is highlighted.
Please sign in to leave a comment.
Don't all answer at once guys!