summaryrefslogtreecommitdiff
path: root/tests/functional/u/useless/useless_with_lock.py
blob: 19d664084da98acac395a746ede453be4a73b26f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""Tests for the useless-with-lock message"""
# pylint: disable=missing-docstring
import threading
from threading import Lock, RLock, Condition, Semaphore, BoundedSemaphore


with threading.Lock():  # [useless-with-lock]
    ...

with Lock():  # [useless-with-lock]
    ...

with threading.Lock() as this_shouldnt_matter:  # [useless-with-lock]
    ...

with threading.RLock():  # [useless-with-lock]
    ...

with RLock():  # [useless-with-lock]
    ...

with threading.Condition():  # [useless-with-lock]
    ...

with Condition():  # [useless-with-lock]
    ...

with threading.Semaphore():  # [useless-with-lock]
    ...

with Semaphore():  # [useless-with-lock]
    ...

with threading.BoundedSemaphore():  # [useless-with-lock]
    ...

with BoundedSemaphore():  # [useless-with-lock]
    ...

lock = threading.Lock()
with lock:  # this is ok
    ...

rlock = threading.RLock()
with rlock:  # this is ok
    ...

cond = threading.Condition()
with cond:  # this is ok
    ...

sem = threading.Semaphore()
with sem:  # this is ok
    ...

b_sem = threading.BoundedSemaphore()
with b_sem:  # this is ok
    ...