@@ -144,23 +144,27 @@ fn check_annotation<'a>(checker: &mut Checker, annotation: &'a Expr) {
144144 // Generate the flattened fix once.
145145 let fix = if let & [ edit_expr] = necessary_nodes. as_slice ( ) {
146146 // Generate a [`Fix`] for a single type expression, e.g. `int`.
147- Fix :: applicable_edit (
147+ Some ( Fix :: applicable_edit (
148148 Edit :: range_replacement ( checker. generator ( ) . expr ( edit_expr) , annotation. range ( ) ) ,
149149 applicability,
150- )
150+ ) )
151151 } else {
152152 match union_type {
153- UnionKind :: PEP604 => {
154- generate_pep604_fix ( checker, necessary_nodes, annotation, applicability)
155- }
153+ UnionKind :: PEP604 => Some ( generate_pep604_fix (
154+ checker,
155+ necessary_nodes,
156+ annotation,
157+ applicability,
158+ ) ) ,
156159 UnionKind :: TypingUnion => {
157- generate_union_fix ( checker, necessary_nodes, annotation, applicability)
158- . ok ( )
159- . unwrap ( )
160+ generate_union_fix ( checker, necessary_nodes, annotation, applicability) . ok ( )
160161 }
161162 }
162163 } ;
163- diagnostic. set_fix ( fix) ;
164+
165+ if let Some ( fix) = fix {
166+ diagnostic. set_fix ( fix) ;
167+ }
164168 } ;
165169
166170 checker. diagnostics . push ( diagnostic) ;
@@ -224,7 +228,7 @@ enum UnionKind {
224228 PEP604 ,
225229}
226230
227- // Generate a [`Fix`] for two or more type expressions, e.g. `int | float | complex`.
231+ /// Generate a [`Fix`] for two or more type expressions, e.g. `int | float | complex`.
228232fn generate_pep604_fix (
229233 checker : & Checker ,
230234 nodes : Vec < & Expr > ,
@@ -255,7 +259,7 @@ fn generate_pep604_fix(
255259 )
256260}
257261
258- // Generate a [`Fix`] for two or more type expresisons, e.g. `typing.Union[int, float, complex]`.
262+ /// Generate a [`Fix`] for two or more type expresisons, e.g. `typing.Union[int, float, complex]`.
259263fn generate_union_fix (
260264 checker : & Checker ,
261265 nodes : Vec < & Expr > ,
0 commit comments