1
1
-- -
2
2
source : crates / ruff_linter / src / rules / pycodestyle / mod .rs
3
3
-- -
4
- E721 .py :2 :4 : E721 Do not compare types , use ` isinstance()`
4
+ E721 .py :2 :4 : E721 Use ` is ` and ` is not` for type comparisons , or `isinstance ()` for isinstance checks
5
5
|
6
6
1 | #: E721
7
7
2 | if type (res ) == type (42 ):
@@ -10,7 +10,7 @@ E721.py:2:4: E721 Do not compare types, use `isinstance()`
10
10
4 | #: E721
11
11
|
12
12
13
- E721 .py :5 :4 : E721 Do not compare types , use ` isinstance()`
13
+ E721 .py :5 :4 : E721 Use ` is ` and ` is not` for type comparisons , or `isinstance ()` for isinstance checks
14
14
|
15
15
3 | pass
16
16
4 | #: E721
@@ -20,7 +20,7 @@ E721.py:5:4: E721 Do not compare types, use `isinstance()`
20
20
7 | #: E721
21
21
|
22
22
23
- E721 .py :8 :4 : E721 Do not compare types , use ` isinstance()`
23
+ E721 .py :8 :4 : E721 Use ` is ` and ` is not` for type comparisons , or `isinstance ()` for isinstance checks
24
24
|
25
25
6 | pass
26
26
7 | #: E721
@@ -30,17 +30,7 @@ E721.py:8:4: E721 Do not compare types, use `isinstance()`
30
30
10 | #: Okay
31
31
|
32
32
33
- E721 .py :18 :4 : E721 Do not compare types , use ` isinstance()`
34
- |
35
- 16 | import types
36
- 17 |
37
- 18 | if type (res ) is not types .ListType :
38
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E721
39
- 19 | pass
40
- 20 | #: E721
41
- |
42
-
43
- E721 .py :21 :8 : E721 Do not compare types , use ` isinstance()`
33
+ E721 .py :21 :8 : E721 Use ` is` and ` is not` for type comparisons , or `isinstance ()` for isinstance checks
44
34
|
45
35
19 | pass
46
36
20 | #: E721
@@ -50,7 +40,7 @@ E721.py:21:8: E721 Do not compare types, use `isinstance()`
50
40
23 | assert type (res ) == type ([])
51
41
|
52
42
53
- E721 .py :23 :8 : E721 Do not compare types , use ` isinstance()`
43
+ E721 .py :23 :8 : E721 Use ` is ` and ` is not` for type comparisons , or `isinstance ()` for isinstance checks
54
44
|
55
45
21 | assert type (res ) == type (False ) or type (res ) == type (None )
56
46
22 | #: E721
@@ -60,7 +50,7 @@ E721.py:23:8: E721 Do not compare types, use `isinstance()`
60
50
25 | assert type (res ) == type (())
61
51
|
62
52
63
- E721 .py :25 :8 : E721 Do not compare types , use ` isinstance()`
53
+ E721 .py :25 :8 : E721 Use ` is ` and ` is not` for type comparisons , or `isinstance ()` for isinstance checks
64
54
|
65
55
23 | assert type (res ) == type ([])
66
56
24 | #: E721
@@ -70,7 +60,7 @@ E721.py:25:8: E721 Do not compare types, use `isinstance()`
70
60
27 | assert type (res ) == type ((0 ,))
71
61
|
72
62
73
- E721 .py :27 :8 : E721 Do not compare types , use ` isinstance()`
63
+ E721 .py :27 :8 : E721 Use ` is ` and ` is not` for type comparisons , or `isinstance ()` for isinstance checks
74
64
|
75
65
25 | assert type (res ) == type (())
76
66
26 | #: E721
@@ -80,7 +70,7 @@ E721.py:27:8: E721 Do not compare types, use `isinstance()`
80
70
29 | assert type (res ) == type ((0 ))
81
71
|
82
72
83
- E721 .py :29 :8 : E721 Do not compare types , use ` isinstance()`
73
+ E721 .py :29 :8 : E721 Use ` is ` and ` is not` for type comparisons , or `isinstance ()` for isinstance checks
84
74
|
85
75
27 | assert type (res ) == type ((0 ,))
86
76
28 | #: E721
@@ -90,7 +80,7 @@ E721.py:29:8: E721 Do not compare types, use `isinstance()`
90
80
31 | assert type (res ) != type ((1 , ))
91
81
|
92
82
93
- E721 .py :31 :8 : E721 Do not compare types , use ` isinstance()`
83
+ E721 .py :31 :8 : E721 Use ` is ` and ` is not` for type comparisons , or `isinstance ()` for isinstance checks
94
84
|
95
85
29 | assert type (res ) == type ((0 ))
96
86
30 | #: E721
@@ -100,27 +90,7 @@ E721.py:31:8: E721 Do not compare types, use `isinstance()`
100
90
33 | assert type (res ) is type ((1 , ))
101
91
|
102
92
103
- E721 .py :33 :8 : E721 Do not compare types , use ` isinstance()`
104
- |
105
- 31 | assert type (res ) != type ((1 , ))
106
- 32 | #: Okay
107
- 33 | assert type (res ) is type ((1 , ))
108
- | ^^^^^^^^^^^^^^^^^^^^^^^^ E721
109
- 34 | #: Okay
110
- 35 | assert type (res ) is not type ((1 , ))
111
- |
112
-
113
- E721 .py :35 :8 : E721 Do not compare types , use ` isinstance()`
114
- |
115
- 33 | assert type (res ) is type ((1 , ))
116
- 34 | #: Okay
117
- 35 | assert type (res ) is not type ((1 , ))
118
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E721
119
- 36 | #: E211 E721
120
- 37 | assert type (res ) == type ([2 , ])
121
- |
122
-
123
- E721 .py :37 :8 : E721 Do not compare types , use ` isinstance()`
93
+ E721 .py :37 :8 : E721 Use ` is` and ` is not` for type comparisons , or `isinstance ()` for isinstance checks
124
94
|
125
95
35 | assert type (res ) is not type ((1 , ))
126
96
36 | #: E211 E721
@@ -130,7 +100,7 @@ E721.py:37:8: E721 Do not compare types, use `isinstance()`
130
100
39 | assert type (res ) == type ( ( ) )
131
101
|
132
102
133
- E721 .py :39 :8 : E721 Do not compare types , use ` isinstance()`
103
+ E721 .py :39 :8 : E721 Use ` is ` and ` is not` for type comparisons , or `isinstance ()` for isinstance checks
134
104
|
135
105
37 | assert type (res ) == type ([2 , ])
136
106
38 | #: E201 E201 E202 E721
@@ -140,7 +110,7 @@ E721.py:39:8: E721 Do not compare types, use `isinstance()`
140
110
41 | assert type (res ) == type ( (0 , ) )
141
111
|
142
112
143
- E721 .py :41 :8 : E721 Do not compare types , use ` isinstance()`
113
+ E721 .py :41 :8 : E721 Use ` is ` and ` is not` for type comparisons , or `isinstance ()` for isinstance checks
144
114
|
145
115
39 | assert type (res ) == type ( ( ) )
146
116
40 | #: E201 E202 E721
@@ -149,25 +119,26 @@ E721.py:41:8: E721 Do not compare types, use `isinstance()`
149
119
42 | #:
150
120
|
151
121
152
- E721 .py :107 :12 : E721 Do not compare types , use ` isinstance()`
153
- |
154
- 105 | def asdf (self , value : str | None ):
155
- 106 | #: E721
156
- 107 | if type (value ) is str :
157
- | ^^^^^^^^^^^^^^^^^^ E721
158
- 108 | ...
159
- |
122
+ E721 .py :59 :4 : E721 Use ` is` and ` is not` for type comparisons , or `isinstance ()` for isinstance checks
123
+ |
124
+ 57 | pass
125
+ 58 | #: E721
126
+ 59 | if type (res ) == type :
127
+ | ^^^^^^^^^^^^^^^^^ E721
128
+ 60 | pass
129
+ 61 | #: Okay
130
+ |
160
131
161
- E721 .py :117 : 12 : E721 Do not compare types , use ` isinstance()`
132
+ E721 .py :140 : 1 : E721 Use ` is ` and ` is not` for type comparisons , or `isinstance ()` for isinstance checks
162
133
|
163
- 115 | def asdf ( self , value : str | None ):
164
- 116 | #: E721
165
- 117 | if type ( value ) is str :
166
- | ^^^^^^^^^^^^^^^^^^ E721
167
- 118 | ...
134
+ 139 | #: E721
135
+ 140 | dtype == float
136
+ | ^^^^^^^^^^^^^^ E721
137
+ 141 |
138
+ 142 | import builtins
168
139
|
169
140
170
- E721 .py :144 :4 : E721 Do not compare types , use ` isinstance()`
141
+ E721 .py :144 :4 : E721 Use ` is ` and ` is not` for type comparisons , or `isinstance ()` for isinstance checks
171
142
|
172
143
142 | import builtins
173
144
143 |
0 commit comments