From a9cdff900e86f2cabf38847c8589e0d6ab82d69c Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Fri, 18 Aug 2023 16:16:47 +0200 Subject: [PATCH] _variable should be an external global function rather than a class property. The combination of `@property` + `@classmethod` isn't supported on Python < 3.9. --- platypush/plugins/rss/__init__.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/platypush/plugins/rss/__init__.py b/platypush/plugins/rss/__init__.py index becb09832..e7616292c 100644 --- a/platypush/plugins/rss/__init__.py +++ b/platypush/plugins/rss/__init__.py @@ -18,6 +18,12 @@ from platypush.plugins.variable import VariablePlugin from platypush.schemas.rss import RssFeedEntrySchema +def _variable() -> VariablePlugin: + var = get_plugin(VariablePlugin) + assert var, 'Could not load the variable plugin' + return var + + class RssPlugin(RunnablePlugin): """ A plugin for parsing and subscribing to RSS feeds. @@ -63,13 +69,6 @@ class RssPlugin(RunnablePlugin): self.subscriptions = list(self._parse_subscriptions(subscriptions or [])) self._latest_timestamps = {} - @classmethod - @property - def _variable(cls) -> VariablePlugin: - var = get_plugin(VariablePlugin) - assert var, 'Could not load the variable plugin' - return var - @staticmethod def _get_feed_latest_timestamp_varname(url: str) -> str: return f'LATEST_FEED_TIMESTAMP[{url}]' @@ -77,7 +76,7 @@ class RssPlugin(RunnablePlugin): @classmethod def _get_feed_latest_timestamp(cls, url: str) -> Optional[datetime.datetime]: varname = cls._get_feed_latest_timestamp_varname(url) - var: dict = cls._variable.get(varname).output or {} # type: ignore + var: dict = _variable().get(varname).output or {} # type: ignore t = var.get(varname) if t: @@ -89,7 +88,7 @@ class RssPlugin(RunnablePlugin): return {url: self._get_feed_latest_timestamp(url) for url in self.subscriptions} def _update_latest_timestamps(self) -> None: - self._variable.set( + _variable().set( **{ self._get_feed_latest_timestamp_varname(url): latest_timestamp for url, latest_timestamp in self._latest_timestamps.items()