@@ -235,19 +235,32 @@ and tuple_concatenation_problem =
235235 | UnpackingNonIterable of { annotation : Type .t }
236236[@@ deriving compare, eq, sexp, show, hash]
237237
238- type invalid_decoration = {
239- decorator : Decorator .t ;
240- reason : invalid_decoration_reason ;
241- }
242-
243- and invalid_decoration_reason =
244- | CouldNotResolve
245- | CouldNotResolveArgument of Expression. t
246- | NonCallableDecoratorFactory of Type. t
247- | NonCallableDecorator of Type. t
248- | DecoratorFactoryFailedToApply of kind option
249- | ApplicationFailed of kind option
238+ type invalid_decoration =
239+ | CouldNotResolve of Expression .t
240+ | CouldNotResolveArgument of {
241+ name : Reference .t ;
242+ argument : Expression .t ;
243+ }
244+ | NonCallableDecoratorFactory of {
245+ name : Reference .t ;
246+ annotation : Type .t ;
247+ }
248+ | NonCallableDecorator of {
249+ name : Reference .t ;
250+ has_arguments : bool ;
251+ annotation : Type .t ;
252+ }
253+ | DecoratorFactoryFailedToApply of {
254+ name : Reference .t ;
255+ reason : kind option ;
256+ }
257+ | ApplicationFailed of {
258+ name : Reference .t ;
259+ has_arguments : bool ;
260+ reason : kind option ;
261+ }
250262 | SetterNameMismatch of {
263+ name : Reference .t ;
251264 actual : string ;
252265 expected : string ;
253266 }
@@ -1109,11 +1122,14 @@ let rec messages ~concise ~signature location kind =
11091122 variable
11101123 unconcatenatable;
11111124 ])
1112- | InvalidDecoration { decorator = { name; _ } ; reason = CouldNotResolve } ->
1113- let name = Node. value name |> Reference. sanitized |> Reference. show in
1114- [Format. asprintf " Pyre was not able to infer the type of the decorator `%s`." name]
1115- | InvalidDecoration { decorator = { name; _ } ; reason = CouldNotResolveArgument argument } ->
1116- let name = Node. value name |> Reference. sanitized |> Reference. show in
1125+ | InvalidDecoration (CouldNotResolve expression ) ->
1126+ [
1127+ Format. asprintf
1128+ " Pyre was not able to infer the type of the decorator `%s`."
1129+ (show_sanitized_expression expression);
1130+ ]
1131+ | InvalidDecoration (CouldNotResolveArgument { name; argument } ) ->
1132+ let name = Reference. sanitized name |> Reference. show in
11171133 [
11181134 Format. asprintf
11191135 " Pyre was not able to infer the type of argument `%s` to decorator factory `%s`."
@@ -1122,46 +1138,43 @@ let rec messages ~concise ~signature location kind =
11221138 " This can usually be worked around by extracting your argument into a global variable and \
11231139 providing an explicit type annotation." ;
11241140 ]
1125- | InvalidDecoration { decorator = { name; _ } ; reason = NonCallableDecoratorFactory result } ->
1126- let name = Node. value name |> Reference. sanitized |> Reference. show in
1141+ | InvalidDecoration (NonCallableDecoratorFactory { name; annotation } ) ->
1142+ let name = Reference. sanitized name |> Reference. show in
11271143 [
11281144 Format. asprintf
11291145 " Decorator factory `%s` could not be called, because its type `%a` is not callable."
11301146 name
11311147 pp_type
1132- result ;
1148+ annotation ;
11331149 ]
1134- | InvalidDecoration { decorator = { name; arguments } ; reason = NonCallableDecorator result } ->
1135- let name = Node. value name |> Reference. sanitized |> Reference. show in
1136- let arguments = if Option. is_some arguments then " (...)" else " " in
1150+ | InvalidDecoration (NonCallableDecorator { name; has_arguments; annotation } ) ->
1151+ let name = Reference. sanitized name |> Reference. show in
1152+ let arguments = if has_arguments then " (...)" else " " in
11371153 [
11381154 Format. asprintf
11391155 " Decorator `%s%s` could not be called, because its type `%a` is not callable."
11401156 name
11411157 arguments
11421158 pp_type
1143- result ;
1159+ annotation ;
11441160 ]
1145- | InvalidDecoration
1146- { decorator = { name; _ }; reason = DecoratorFactoryFailedToApply inner_reason } -> (
1147- let name = Node. value name |> Reference. sanitized |> Reference. show in
1161+ | InvalidDecoration (DecoratorFactoryFailedToApply { name; reason } ) -> (
1162+ let name = Reference. sanitized name |> Reference. show in
11481163 let recurse = messages ~concise ~signature location in
1149- match inner_reason >> | recurse >> = List. hd with
1164+ match reason >> | recurse >> = List. hd with
11501165 | Some inner_message ->
11511166 [Format. asprintf " While applying decorator factory `%s`: %s" name inner_message]
11521167 | None -> [Format. asprintf " Decorator factory `%s` failed to apply." name])
1153- | InvalidDecoration { decorator = { name; arguments }; reason = ApplicationFailed inner_reason }
1154- -> (
1155- let name = Node. value name |> Reference. sanitized |> Reference. show in
1156- let arguments = if Option. is_some arguments then " (...)" else " " in
1168+ | InvalidDecoration (ApplicationFailed { name; has_arguments; reason } ) -> (
1169+ let name = Reference. sanitized name |> Reference. show in
1170+ let arguments = if has_arguments then " (...)" else " " in
11571171 let recurse = messages ~concise ~signature location in
1158- match inner_reason >> | recurse >> = List. hd with
1172+ match reason >> | recurse >> = List. hd with
11591173 | Some inner_message ->
11601174 [Format. asprintf " While applying decorator `%s%s`: %s" name arguments inner_message]
11611175 | None -> [Format. asprintf " Decorator `%s%s` failed to apply." name arguments])
1162- | InvalidDecoration { decorator = { name; _ }; reason = SetterNameMismatch { expected; actual } }
1163- ->
1164- let name = Node. value name |> Reference. sanitized |> Reference. show in
1176+ | InvalidDecoration (SetterNameMismatch { name; expected; actual } ) ->
1177+ let name = Reference. sanitized name |> Reference. show in
11651178 [
11661179 Format. asprintf
11671180 " Invalid property setter `%s`: `%s` does not match decorated method `%s`."
@@ -3573,8 +3586,8 @@ let suppress ~mode ~ignore_codes error =
35733586 | InconsistentOverride
35743587 { override = StrengthenedPrecondition (Found { expected = Type. Variable _; _ }); _ } ->
35753588 true
3576- | InvalidDecoration { reason = CouldNotResolve ; _ }
3577- | InvalidDecoration { reason = CouldNotResolveArgument _ ; _ } ->
3589+ | InvalidDecoration ( CouldNotResolve _)
3590+ | InvalidDecoration ( CouldNotResolveArgument _ ) ->
35783591 true
35793592 | InvalidTypeParameters
35803593 { kind = AttributeResolution. IncorrectNumberOfParameters { actual = 0 ; _ }; _ } ->
0 commit comments