lint (flake8) fixes
authorGeorge Sakkis <george.sakkis@gmail.com>
Sun, 19 Apr 2015 18:49:24 +0000 (21:49 +0300)
committerGeorge Sakkis <george.sakkis@gmail.com>
Sun, 19 Apr 2015 18:49:24 +0000 (21:49 +0300)
Makefile
cached_property.py
tests/__init__.py
tests/test_cached_property.py
tests/test_cached_property_ttl.py

index 22ac8b860e13b180b7794affa89faebf4a6a1abe..2446d517f1e14f18cd72abcf9380460c76dd5e82 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -25,7 +25,7 @@ clean-pyc:
        find . -name '*~' -exec rm -f {} +
 
 lint:
-       flake8 cached_property tests
+       flake8 cached_property.py tests
 
 test:
        py.test
index 48e615a56a852210a0a02058d8865db201563f1c..2d5d50cccebff57e62836ed6f7c8a7de781fa91c 100644 (file)
@@ -10,11 +10,11 @@ import threading
 
 
 class cached_property(object):
-    """ A property that is only computed once per instance and then replaces
-        itself with an ordinary attribute. Deleting the attribute resets the
-        property.
-        Source: https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76
-        """
+    """
+    A property that is only computed once per instance and then replaces itself
+    with an ordinary attribute. Deleting the attribute resets the property.
+    Source: https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76
+    """  # noqa
 
     def __init__(self, func):
         self.__doc__ = getattr(func, '__doc__')
@@ -28,9 +28,11 @@ class cached_property(object):
 
 
 class threaded_cached_property(cached_property):
-    """ A cached_property version for use in environments where multiple
-        threads might concurrently try to access the property.
-        """
+    """
+    A cached_property version for use in environments where multiple threads
+    might concurrently try to access the property.
+    """
+
     def __init__(self, func):
         super(threaded_cached_property, self).__init__(func)
         self.lock = threading.RLock()
@@ -48,10 +50,11 @@ class threaded_cached_property(cached_property):
 
 
 class cached_property_with_ttl(object):
-    """ A property that is only computed once per instance and then replaces
-        itself with an ordinary attribute. Setting the ttl to a number expresses
-        how long the property will last before being timed out.
-        """  # noqa
+    """
+    A property that is only computed once per instance and then replaces itself
+    with an ordinary attribute. Setting the ttl to a number expresses how long
+    the property will last before being timed out.
+    """
 
     def __init__(self, ttl=None):
         ttl_or_func = ttl
@@ -97,9 +100,11 @@ timed_cached_property = cached_property_with_ttl
 
 
 class threaded_cached_property_with_ttl(cached_property_with_ttl):
-    """ A cached_property version for use in environments where multiple
-        threads might concurrently try to access the property.
-        """
+    """
+    A cached_property version for use in environments where multiple threads
+    might concurrently try to access the property.
+    """
+
     def __init__(self, ttl=None):
         super(threaded_cached_property_with_ttl, self).__init__(ttl)
         self.lock = threading.RLock()
@@ -113,9 +118,9 @@ class threaded_cached_property_with_ttl(cached_property_with_ttl):
                 return obj._cache[prop_name][0]
 
             # If not, do the calculation and release the lock.
-            return super(threaded_cached_property_with_ttl, self).__get__(obj, cls)
+            return super(threaded_cached_property_with_ttl, self).__get__(obj,
+                                                                          cls)
 
 # Alias to make threaded_cached_property_with_ttl easier to use
 threaded_cached_property_ttl = threaded_cached_property_with_ttl
 timed_threaded_cached_property = threaded_cached_property_with_ttl
-
index 7c68785e9d0b64e1fe46403c4316a9fe1ea36eeb..40a96afc6ff09d58a702b76e3f7dd412fe975e26 100644 (file)
@@ -1 +1 @@
-# -*- coding: utf-8 -*-
\ No newline at end of file
+# -*- coding: utf-8 -*-
index bb4040146445b2e217d1d90e76e2acfd50d30142..40a5ad9d7378e87eb0972ca15695e73af18e930d 100644 (file)
@@ -88,8 +88,9 @@ class TestCachedProperty(unittest.TestCase):
         self.assertEqual(c.add_cached, None)
 
     def test_threads(self):
-        """ How well does the standard cached_property implementation work with threads?
-            Short answer: It doesn't! Use threaded_cached_property instead!
+        """
+        How well does the standard cached_property implementation work with
+        threads? It doesn't, use threaded_cached_property instead!
         """
 
         class Check(object):
index 2470d60e7381c34acb50a279a23dbd791d3fae43..5802516d70851a41bcf87e41f0d5e9b5feee2fed 100644 (file)
@@ -7,8 +7,11 @@ test_threaded_cache_property.py
 Tests for `cached-property` module, cached_property_with_ttl.
 Tests for `cached-property` module, threaded_cache_property_with_ttl.
 """
+
 import unittest
 from freezegun import freeze_time
+from time import sleep
+from threading import Lock, Thread
 
 from cached_property import (
     cached_property_with_ttl,
@@ -16,14 +19,6 @@ from cached_property import (
 )
 
 
-from time import sleep
-from threading import Lock, Thread
-import unittest
-from freezegun import freeze_time
-
-from cached_property import cached_property
-
-
 class TestCachedPropertyWithTTL(unittest.TestCase):
 
     def test_cached_property(self):