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.ScoreCardHowever, 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_scoreI 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: _ScorecardClassThe 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!
Please try upgrading IDE to the latest version, disabling all non-bundled plugins (**Settings | Plugins**, click the cog icon -> Disable All Downloaded Plugins) and check if the problem persists.
If the problem remains unresolved, we would like to investigate it properly. Please create an issue on YouTrack (https://youtrack.jetbrains.com/newIssue) regarding this problem. Attach relevant logs (Help | Collect Logs and Diagnostic Data), screenshots, precise steps for reproducing the issue and a runnable code/project sample if needed.
For urgent inquiries, please use Help | Contact Support in the IDE.
Hi, thanks for the update.
I just got round to testing this in the latest PyCharm 2025.1.3.1 and it's now working, which is great.
Update: I can now see the autocomplete property list, which is the main thing. However, the docstrings are not rendered for any properties that have them. I have followed the convention of adding a docstring only to the getter.
Please create a new report on YouTrack and provide the mentioned example so we can try to replicate it - Also, make sure to check on 2025.2.2