diff --git a/ChangeLog b/ChangeLog index 5b1fc4dfc0..82871c14b5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,10 @@ Release date: TBA Closes PyCQA/pylint#8074 +* Add ``Lock`` to the ``multiprocessing`` brain. + + Closes PyCQA/pylint#3313 + What's New in astroid 2.13.3? ============================= diff --git a/astroid/brain/brain_multiprocessing.py b/astroid/brain/brain_multiprocessing.py index fc98a06c2f..c349bbefc1 100644 --- a/astroid/brain/brain_multiprocessing.py +++ b/astroid/brain/brain_multiprocessing.py @@ -78,6 +78,7 @@ class SyncManager(object): Queue = JoinableQueue = queue.Queue Event = threading.Event RLock = threading.RLock + Lock = threading.Lock BoundedSemaphore = threading.BoundedSemaphore Condition = threading.Condition Barrier = threading.Barrier diff --git a/astroid/brain/brain_threading.py b/astroid/brain/brain_threading.py index a85055d871..061b11fcfd 100644 --- a/astroid/brain/brain_threading.py +++ b/astroid/brain/brain_threading.py @@ -22,7 +22,7 @@ def __exit__(self, *args): def locked(self): return False - def Lock(): + def Lock(*args, **kwargs): return lock() """ ) diff --git a/tests/unittest_brain.py b/tests/unittest_brain.py index 0ffccb3542..30594c385f 100644 --- a/tests/unittest_brain.py +++ b/tests/unittest_brain.py @@ -711,6 +711,7 @@ def test_multiprocessing_manager(self) -> None: joinable_queue = manager.JoinableQueue() event = manager.Event() rlock = manager.RLock() + lock = manager.Lock() bounded_semaphore = manager.BoundedSemaphore() condition = manager.Condition() barrier = manager.Barrier() @@ -736,6 +737,10 @@ def test_multiprocessing_manager(self) -> None: rlock_name = "threading._RLock" self.assertEqual(rlock.qname(), rlock_name) + lock = next(module["lock"].infer()) + lock_name = "threading.lock" + self.assertEqual(lock.qname(), lock_name) + bounded_semaphore = next(module["bounded_semaphore"].infer()) semaphore_name = "threading.BoundedSemaphore" self.assertEqual(bounded_semaphore.qname(), semaphore_name)