From edc46a8ae67598281c442e6064bde4b79e623189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Sat, 2 Jun 2018 11:48:34 +0200 Subject: [PATCH] Rename LazyInitialise to make IDEs recognise it as a property --- lib/envvars/__init__.py | 4 ++-- lib/tfw/decorators/__init__.py | 2 +- lib/tfw/decorators/{lazy_initialise.py => lazy_property.py} | 2 +- lib/tfw/mixins/callback_mixin.py | 4 ++-- lib/tfw/mixins/observer_mixin.py | 4 ++-- lib/tfw/mixins/supervisor_mixin.py | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) rename lib/tfw/decorators/{lazy_initialise.py => lazy_property.py} (96%) diff --git a/lib/envvars/__init__.py b/lib/envvars/__init__.py index 11faa64..b5d9503 100644 --- a/lib/envvars/__init__.py +++ b/lib/envvars/__init__.py @@ -4,7 +4,7 @@ from collections import namedtuple from os import environ -from tfw.decorators import LazyInitialise +from tfw.decorators import lazy_property class LazyEnvironment: @@ -12,7 +12,7 @@ class LazyEnvironment: self._prefix = prefix self._tuple_name = tuple_name - @LazyInitialise + @lazy_property def environment(self): return self.prefixed_envvars_to_namedtuple() diff --git a/lib/tfw/decorators/__init__.py b/lib/tfw/decorators/__init__.py index cd61318..ed79d7f 100644 --- a/lib/tfw/decorators/__init__.py +++ b/lib/tfw/decorators/__init__.py @@ -2,4 +2,4 @@ # All Rights Reserved. See LICENSE file for details. from .rate_limiter import RateLimiter -from .lazy_initialise import LazyInitialise +from .lazy_property import lazy_property diff --git a/lib/tfw/decorators/lazy_initialise.py b/lib/tfw/decorators/lazy_property.py similarity index 96% rename from lib/tfw/decorators/lazy_initialise.py rename to lib/tfw/decorators/lazy_property.py index 4fdd3a3..80ddbeb 100644 --- a/lib/tfw/decorators/lazy_initialise.py +++ b/lib/tfw/decorators/lazy_property.py @@ -2,7 +2,7 @@ # All Rights Reserved. See LICENSE file for details. -class LazyInitialise: +class lazy_property: """ Decorator that replaces a function with the value it calculates on the first call. diff --git a/lib/tfw/mixins/callback_mixin.py b/lib/tfw/mixins/callback_mixin.py index 971de5c..de0de6c 100644 --- a/lib/tfw/mixins/callback_mixin.py +++ b/lib/tfw/mixins/callback_mixin.py @@ -3,11 +3,11 @@ from functools import partial -from tfw.decorators import LazyInitialise +from tfw.decorators import lazy_property class CallbackMixin: - @LazyInitialise + @lazy_property def _callbacks(self): return [] diff --git a/lib/tfw/mixins/observer_mixin.py b/lib/tfw/mixins/observer_mixin.py index 198c405..712a31e 100644 --- a/lib/tfw/mixins/observer_mixin.py +++ b/lib/tfw/mixins/observer_mixin.py @@ -3,11 +3,11 @@ from watchdog.observers import Observer -from tfw.decorators import LazyInitialise +from tfw.decorators import lazy_property class ObserverMixin: - @LazyInitialise + @lazy_property def observer(self): return Observer() diff --git a/lib/tfw/mixins/supervisor_mixin.py b/lib/tfw/mixins/supervisor_mixin.py index bdd43ea..00cf398 100644 --- a/lib/tfw/mixins/supervisor_mixin.py +++ b/lib/tfw/mixins/supervisor_mixin.py @@ -6,12 +6,12 @@ from xmlrpc.client import Fault as SupervisorFault from contextlib import suppress from os import remove -from tfw.decorators import LazyInitialise +from tfw.decorators import lazy_property from tfw.config import TFWENV class SupervisorBaseMixin: - @LazyInitialise + @lazy_property def supervisor(self): return xmlrpc.client.ServerProxy(TFWENV.SUPERVISOR_HTTP_URI).supervisor