summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2018-09-29 11:37:44 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2018-09-29 11:38:24 +0200
commit5a85ae63fdfc9ab578c856728105a6822d1786fe (patch)
tree9a8a73d73a20cd18606ca6e7f61345caf7180be4
parentb054781a7d27bb96e9c620769b5af1e9c58eaaa9 (diff)
downloadastroid-git-5a85ae63fdfc9ab578c856728105a6822d1786fe.tar.gz
``threading.Lock.acquire`` has the ``timeout`` parameter now.
Close PyCQA/pylint#2457
-rw-r--r--ChangeLog4
-rw-r--r--astroid/brain/brain_threading.py3
-rw-r--r--astroid/tests/unittest_brain.py13
3 files changed, 17 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 6089bb4e..c7d07132 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,10 @@ What's New in astroid 2.1.0?
============================
Release Date: TBA
+ * ``threading.Lock.acquire`` has the ``timeout`` parameter now.
+
+ Close PyCQA/pylint#2457
+
* Pass parameters by keyword name when inferring sequences.
Close PyCQA/pylint#2526
diff --git a/astroid/brain/brain_threading.py b/astroid/brain/brain_threading.py
index 7c609759..2313fbe4 100644
--- a/astroid/brain/brain_threading.py
+++ b/astroid/brain/brain_threading.py
@@ -4,14 +4,13 @@
# Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
# For details: https://github.com/PyCQA/astroid/blob/master/COPYING.LESSER
-
import astroid
def _thread_transform():
return astroid.parse('''
class lock(object):
- def acquire(self, blocking=True):
+ def acquire(self, blocking=True, timeout=-1):
pass
def release(self):
pass
diff --git a/astroid/tests/unittest_brain.py b/astroid/tests/unittest_brain.py
index 5a2e218f..d7c75f9c 100644
--- a/astroid/tests/unittest_brain.py
+++ b/astroid/tests/unittest_brain.py
@@ -488,7 +488,18 @@ class MultiprocessingBrainTest(unittest.TestCase):
class ThreadingBrainTest(unittest.TestCase):
def test_lock(self):
- self._test_lock_object('Lock')
+ lock_instance = builder.extract_node("""
+ import threading
+ threading.Lock()
+ """)
+ inferred = next(lock_instance.infer())
+ self.assert_is_valid_lock(inferred)
+
+ acquire_method = inferred.getattr('acquire')[0]
+ parameters = [
+ param.name for param in acquire_method.args.args[1:]
+ ]
+ assert parameters == ['blocking', 'timeout']
def test_rlock(self):
self._test_lock_object('RLock')