"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "analysis/analysisError.ml" between
pyre-check-0.0.54.tar.gz and pyre-check-0.0.55.tar.gz

About: Pyre is a performant type checker for Python (ships with Pysa, a security focused static analysis tool).

analysisError.ml  (pyre-check-0.0.54):analysisError.ml  (pyre-check-0.0.55)
skipping to change at line 201 skipping to change at line 201
matching_overload: Type.t Type.Callable.overload; matching_overload: Type.t Type.Callable.overload;
unmatched_location: Location.t; unmatched_location: Location.t;
} }
| Parameters of { | Parameters of {
name: Reference.t; name: Reference.t;
location: Location.t; location: Location.t;
} }
| DifferingDecorators | DifferingDecorators
| MisplacedOverloadDecorator | MisplacedOverloadDecorator
and incompatible_parameter_kind = and unsupported_operand_kind =
| Operand of { | Binary of {
operator_name: Identifier.t; operator_name: Identifier.t;
left_operand: Type.t; left_operand: Type.t;
right_operand: Type.t; right_operand: Type.t;
} }
| Argument of { | Unary of {
name: Identifier.t option; operator_name: Identifier.t;
position: int; operand: Type.t;
callee: Reference.t option;
mismatch: mismatch;
} }
[@@deriving compare, eq, sexp, show, hash] [@@deriving compare, eq, sexp, show, hash]
type invalid_decoration = { type invalid_decoration = {
decorator: Decorator.t; decorator: Decorator.t;
reason: invalid_decoration_reason; reason: invalid_decoration_reason;
} }
and invalid_decoration_reason = and invalid_decoration_reason =
| CouldNotResolve | CouldNotResolve
skipping to change at line 244 skipping to change at line 242
annotation: Type.t; annotation: Type.t;
test: Expression.t; test: Expression.t;
} }
| IncompatibleAsyncGeneratorReturnType of Type.t | IncompatibleAsyncGeneratorReturnType of Type.t
| IncompatibleAttributeType of { | IncompatibleAttributeType of {
parent: Type.t; parent: Type.t;
incompatible_type: incompatible_type; incompatible_type: incompatible_type;
} }
| IncompatibleAwaitableType of Type.t | IncompatibleAwaitableType of Type.t
| IncompatibleConstructorAnnotation of Type.t | IncompatibleConstructorAnnotation of Type.t
| IncompatibleParameterType of incompatible_parameter_kind | IncompatibleParameterType of {
name: Identifier.t option;
position: int;
callee: Reference.t option;
mismatch: mismatch;
}
| IncompatibleReturnType of { | IncompatibleReturnType of {
mismatch: mismatch; mismatch: mismatch;
is_implicit: bool; is_implicit: bool;
is_unimplemented: bool; is_unimplemented: bool;
define_location: Location.t; define_location: Location.t;
} }
| IncompatibleVariableType of { | IncompatibleVariableType of {
incompatible_type: incompatible_type; incompatible_type: incompatible_type;
declare_location: Location.WithPath.t; declare_location: Location.WithPath.t;
} }
skipping to change at line 364 skipping to change at line 367
| UninitializedAttribute of { | UninitializedAttribute of {
name: Identifier.t; name: Identifier.t;
parent: Type.t; parent: Type.t;
mismatch: mismatch; mismatch: mismatch;
kind: class_kind; kind: class_kind;
} }
| Unpack of { | Unpack of {
expected_count: int; expected_count: int;
unpack_problem: unpack_problem; unpack_problem: unpack_problem;
} }
| UnsupportedOperand of unsupported_operand_kind
| UnusedIgnore of int list | UnusedIgnore of int list
| UnusedLocalMode of { | UnusedLocalMode of {
unused_mode: Source.local_mode Node.t; unused_mode: Source.local_mode Node.t;
actual_mode: Source.local_mode Node.t; actual_mode: Source.local_mode Node.t;
} }
| TypedDictionaryInvalidOperation of { | TypedDictionaryInvalidOperation of {
typed_dictionary_name: Identifier.t; typed_dictionary_name: Identifier.t;
field_name: Identifier.t; field_name: Identifier.t;
method_name: Identifier.t; method_name: Identifier.t;
mismatch: mismatch; mismatch: mismatch;
skipping to change at line 442 skipping to change at line 446
| InvalidException _ -> 48 | InvalidException _ -> 48
| UnsafeCast _ -> 49 | UnsafeCast _ -> 49
| RedefinedClass _ -> 50 | RedefinedClass _ -> 50
| UnusedLocalMode _ -> 51 | UnusedLocalMode _ -> 51
| PrivateProtocolProperty _ -> 52 | PrivateProtocolProperty _ -> 52
| MissingCaptureAnnotation _ -> 53 | MissingCaptureAnnotation _ -> 53
| TypedDictionaryInvalidOperation _ -> 54 | TypedDictionaryInvalidOperation _ -> 54
| TypedDictionaryInitializationError _ -> 55 | TypedDictionaryInitializationError _ -> 55
| InvalidDecoration _ -> 56 | InvalidDecoration _ -> 56
| IncompatibleAsyncGeneratorReturnType _ -> 57 | IncompatibleAsyncGeneratorReturnType _ -> 57
| UnsupportedOperand _ -> 58
| ParserFailure _ -> 404 | ParserFailure _ -> 404
(* Additional errors. *) (* Additional errors. *)
| UnawaitedAwaitable _ -> 1001 | UnawaitedAwaitable _ -> 1001
| Deobfuscation _ -> 1002 | Deobfuscation _ -> 1002
| DeadStore _ -> 1003 | DeadStore _ -> 1003
let name = function let name = function
| AnalysisFailure _ -> "Analysis failure" | AnalysisFailure _ -> "Analysis failure"
| ParserFailure _ -> "Parsing failure" | ParserFailure _ -> "Parsing failure"
| DeadStore _ -> "Dead store" | DeadStore _ -> "Dead store"
skipping to change at line 503 skipping to change at line 508
| TypedDictionaryAccessWithNonLiteral _ -> "TypedDict accessed with a non-lite ral" | TypedDictionaryAccessWithNonLiteral _ -> "TypedDict accessed with a non-lite ral"
| TypedDictionaryInitializationError _ -> "TypedDict initialization error" | TypedDictionaryInitializationError _ -> "TypedDict initialization error"
| TypedDictionaryInvalidOperation _ -> "Invalid TypedDict operation" | TypedDictionaryInvalidOperation _ -> "Invalid TypedDict operation"
| TypedDictionaryKeyNotFound _ -> "TypedDict accessed with a missing key" | TypedDictionaryKeyNotFound _ -> "TypedDict accessed with a missing key"
| UnawaitedAwaitable _ -> "Unawaited awaitable" | UnawaitedAwaitable _ -> "Unawaited awaitable"
| UnboundName _ -> "Unbound name" | UnboundName _ -> "Unbound name"
| UndefinedAttribute _ -> "Undefined attribute" | UndefinedAttribute _ -> "Undefined attribute"
| UndefinedImport _ -> "Undefined import" | UndefinedImport _ -> "Undefined import"
| UndefinedType _ -> "Undefined or invalid type" | UndefinedType _ -> "Undefined or invalid type"
| UnexpectedKeyword _ -> "Unexpected keyword" | UnexpectedKeyword _ -> "Unexpected keyword"
| UnsafeCast _ -> "Unsafe cast"
| UninitializedAttribute _ -> "Uninitialized attribute" | UninitializedAttribute _ -> "Uninitialized attribute"
| Unpack _ -> "Unable to unpack" | Unpack _ -> "Unable to unpack"
| UnsafeCast _ -> "Unsafe cast"
| UnsupportedOperand _ -> "Unsupported operand"
| UnusedIgnore _ -> "Unused ignore" | UnusedIgnore _ -> "Unused ignore"
| UnusedLocalMode _ -> "Unused local mode" | UnusedLocalMode _ -> "Unused local mode"
let weaken_literals kind = let weaken_literals kind =
let weaken_mismatch { actual; expected; due_to_invariance } = let weaken_mismatch { actual; expected; due_to_invariance } =
let actual = let actual =
if Type.contains_literal expected then if Type.contains_literal expected then
actual actual
else else
Type.weaken_literals actual Type.weaken_literals actual
skipping to change at line 547 skipping to change at line 553
variable with variable with
incompatible_type = { incompatible with mismatch = weaken_mismatch mis match }; incompatible_type = { incompatible with mismatch = weaken_mismatch mis match };
} }
| InconsistentOverride ({ override = WeakenedPostcondition mismatch; _ } as in consistent) -> | InconsistentOverride ({ override = WeakenedPostcondition mismatch; _ } as in consistent) ->
InconsistentOverride InconsistentOverride
{ inconsistent with override = WeakenedPostcondition (weaken_mismatch mi smatch) } { inconsistent with override = WeakenedPostcondition (weaken_mismatch mi smatch) }
| InconsistentOverride | InconsistentOverride
({ override = StrengthenedPrecondition (Found mismatch); _ } as inconsiste nt) -> ({ override = StrengthenedPrecondition (Found mismatch); _ } as inconsiste nt) ->
InconsistentOverride InconsistentOverride
{ inconsistent with override = StrengthenedPrecondition (Found (weaken_m ismatch mismatch)) } { inconsistent with override = StrengthenedPrecondition (Found (weaken_m ismatch mismatch)) }
| IncompatibleParameterType (Operand { operator_name; left_operand; right_oper | IncompatibleParameterType ({ mismatch; _ } as incompatible) ->
and }) -> IncompatibleParameterType { incompatible with mismatch = weaken_mismatch m
IncompatibleParameterType ismatch }
(Operand
{
operator_name;
left_operand = Type.weaken_literals left_operand;
right_operand = Type.weaken_literals right_operand;
})
| IncompatibleParameterType (Argument ({ mismatch; _ } as incompatible)) ->
IncompatibleParameterType (Argument { incompatible with mismatch = weaken_
mismatch mismatch })
| IncompatibleReturnType ({ mismatch; _ } as incompatible) -> | IncompatibleReturnType ({ mismatch; _ } as incompatible) ->
IncompatibleReturnType { incompatible with mismatch = weaken_mismatch mism atch } IncompatibleReturnType { incompatible with mismatch = weaken_mismatch mism atch }
| UninitializedAttribute ({ mismatch; _ } as uninitialized) -> | UninitializedAttribute ({ mismatch; _ } as uninitialized) ->
UninitializedAttribute { uninitialized with mismatch = weaken_mismatch mis match } UninitializedAttribute { uninitialized with mismatch = weaken_mismatch mis match }
| MissingAttributeAnnotation { parent; missing_annotation } -> | MissingAttributeAnnotation { parent; missing_annotation } ->
MissingAttributeAnnotation MissingAttributeAnnotation
{ parent; missing_annotation = weaken_missing_annotation missing_annotat ion } { parent; missing_annotation = weaken_missing_annotation missing_annotat ion }
| MissingGlobalAnnotation missing_annotation -> | MissingGlobalAnnotation missing_annotation ->
MissingGlobalAnnotation (weaken_missing_annotation missing_annotation) MissingGlobalAnnotation (weaken_missing_annotation missing_annotation)
| MissingParameterAnnotation missing_annotation -> | MissingParameterAnnotation missing_annotation ->
MissingParameterAnnotation (weaken_missing_annotation missing_annotation) MissingParameterAnnotation (weaken_missing_annotation missing_annotation)
| MissingReturnAnnotation missing_annotation -> | MissingReturnAnnotation missing_annotation ->
MissingReturnAnnotation (weaken_missing_annotation missing_annotation) MissingReturnAnnotation (weaken_missing_annotation missing_annotation)
| ProhibitedAny { is_type_alias; missing_annotation } -> | ProhibitedAny { is_type_alias; missing_annotation } ->
ProhibitedAny ProhibitedAny
{ is_type_alias; missing_annotation = weaken_missing_annotation missing_ annotation } { is_type_alias; missing_annotation = weaken_missing_annotation missing_ annotation }
| UnsupportedOperand (Binary { operator_name; left_operand; right_operand }) -
>
UnsupportedOperand
(Binary
{
operator_name;
left_operand = Type.weaken_literals left_operand;
right_operand = Type.weaken_literals right_operand;
})
| UnsupportedOperand (Unary { operator_name; operand }) ->
UnsupportedOperand (Unary { operator_name; operand = Type.weaken_literals
operand })
| Unpack { expected_count; unpack_problem = UnacceptableType annotation } -> | Unpack { expected_count; unpack_problem = UnacceptableType annotation } ->
Unpack { expected_count; unpack_problem = UnacceptableType (Type.weaken_li terals annotation) } Unpack { expected_count; unpack_problem = UnacceptableType (Type.weaken_li terals annotation) }
| IncompatibleAwaitableType annotation -> | IncompatibleAwaitableType annotation ->
IncompatibleAwaitableType (Type.weaken_literals annotation) IncompatibleAwaitableType (Type.weaken_literals annotation)
| NotCallable annotation -> NotCallable (Type.weaken_literals annotation) | NotCallable annotation -> NotCallable (Type.weaken_literals annotation)
| TypedDictionaryInvalidOperation ({ mismatch; _ } as record) -> | TypedDictionaryInvalidOperation ({ mismatch; _ } as record) ->
TypedDictionaryInvalidOperation { record with mismatch = weaken_mismatch m ismatch } TypedDictionaryInvalidOperation { record with mismatch = weaken_mismatch m ismatch }
| TypedDictionaryInitializationError mismatch -> | TypedDictionaryInitializationError mismatch ->
let mismatch = let mismatch =
match mismatch with match mismatch with
skipping to change at line 744 skipping to change at line 752
"The implementation of `%a` does not accept all possible arguments of overload \ "The implementation of `%a` does not accept all possible arguments of overload \
defined on line `%d`." defined on line `%d`."
pp_reference pp_reference
name name
(Location.line location); (Location.line location);
] ]
| DifferingDecorators -> | DifferingDecorators ->
["This definition does not have the same decorators as the preceding o verload(s)."] ["This definition does not have the same decorators as the preceding o verload(s)."]
| MisplacedOverloadDecorator -> | MisplacedOverloadDecorator ->
["The @overload decorator must be the topmost decorator if present."] ) ["The @overload decorator must be the topmost decorator if present."] )
| IncompatibleParameterType (Operand { operator_name; left_operand; right_oper
and }) ->
[
Format.asprintf
"`%s` is not supported for operand types `%a` and `%a`."
operator_name
pp_type
left_operand
pp_type
right_operand;
]
| IncompatibleParameterType | IncompatibleParameterType
(Argument { name; position; callee; mismatch = { actual; expected; due_to_ { name; position; callee; mismatch = { actual; expected; due_to_invariance
invariance; _ } }) ; _ } } ->
->
let trace = let trace =
if due_to_invariance then if due_to_invariance then
[Format.asprintf "This call might modify the type of the parameter."; invariance_message] [Format.asprintf "This call might modify the type of the parameter."; invariance_message]
else else
[] []
in in
let target = let target =
let parameter = let parameter =
match name with match name with
| Some name -> Format.asprintf "parameter `%a`" pp_identifier name | Some name -> Format.asprintf "parameter `%a`" pp_identifier name
skipping to change at line 1824 skipping to change at line 1821
( Format.asprintf "%a" pp_type original, ( Format.asprintf "%a" pp_type original,
Format.asprintf " (inferred: `%a`)" pp_type annotation ) Format.asprintf " (inferred: `%a`)" pp_type annotation )
in in
[ [
Format.asprintf Format.asprintf
"Revealed type for `%s` is `%s`%s." "Revealed type for `%s` is `%s`%s."
(show_sanitized_expression expression) (show_sanitized_expression expression)
annotation annotation
detail; detail;
] ]
| UnsupportedOperand (Binary { operator_name; left_operand; right_operand }) -
>
[
Format.asprintf
"`%s` is not supported for operand types `%a` and `%a`."
operator_name
pp_type
left_operand
pp_type
right_operand;
]
| UnsupportedOperand (Unary { operator_name; operand }) ->
[
Format.asprintf
"`%s` is not supported for right operand type `%a`."
operator_name
pp_type
operand;
]
| UnsafeCast { expression; annotation } when concise -> | UnsafeCast { expression; annotation } when concise ->
[ [
Format.asprintf Format.asprintf
"`safe_cast` `%a` is not a subclass of `%s`." "`safe_cast` `%a` is not a subclass of `%s`."
pp_type pp_type
annotation annotation
(show_sanitized_expression expression); (show_sanitized_expression expression);
] ]
| UnsafeCast { expression; annotation } -> | UnsafeCast { expression; annotation } ->
[ [
skipping to change at line 2275 skipping to change at line 2290
type t = error_t [@@deriving compare, sexp] type t = error_t [@@deriving compare, sexp]
end) end)
let due_to_analysis_limitations { kind; _ } = let due_to_analysis_limitations { kind; _ } =
let is_due_to_analysis_limitations annotation = let is_due_to_analysis_limitations annotation =
Type.contains_unknown annotation || Type.is_unbound annotation || Type.is_ty pe_alias annotation Type.contains_unknown annotation || Type.is_unbound annotation || Type.is_ty pe_alias annotation
in in
match kind with match kind with
| ImpossibleAssertion { annotation = actual; _ } | ImpossibleAssertion { annotation = actual; _ }
| IncompatibleAwaitableType actual | IncompatibleAwaitableType actual
| IncompatibleParameterType (Argument { mismatch = { actual; _ }; _ }) | IncompatibleParameterType { mismatch = { actual; _ }; _ }
| TypedDictionaryInvalidOperation { mismatch = { actual; _ }; _ } | TypedDictionaryInvalidOperation { mismatch = { actual; _ }; _ }
| TypedDictionaryInitializationError (FieldTypeMismatch { actual_type = actual ; _ }) | TypedDictionaryInitializationError (FieldTypeMismatch { actual_type = actual ; _ })
| IncompatibleReturnType { mismatch = { actual; _ }; _ } | IncompatibleReturnType { mismatch = { actual; _ }; _ }
| IncompatibleAttributeType { incompatible_type = { mismatch = { actual; _ }; _ }; _ } | IncompatibleAttributeType { incompatible_type = { mismatch = { actual; _ }; _ }; _ }
| IncompatibleVariableType { incompatible_type = { mismatch = { actual; _ }; _ }; _ } | IncompatibleVariableType { incompatible_type = { mismatch = { actual; _ }; _ }; _ }
| InconsistentOverride { override = StrengthenedPrecondition (Found { actual; _ }); _ } | InconsistentOverride { override = StrengthenedPrecondition (Found { actual; _ }); _ }
| InconsistentOverride { override = WeakenedPostcondition { actual; _ }; _ } | InconsistentOverride { override = WeakenedPostcondition { actual; _ }; _ }
| InvalidArgument (Keyword { annotation = actual; _ }) | InvalidArgument (Keyword { annotation = actual; _ })
| InvalidArgument (ConcreteVariable { annotation = actual; _ }) | InvalidArgument (ConcreteVariable { annotation = actual; _ })
| InvalidArgument | InvalidArgument
(ListVariadicVariable { mismatch = NotDefiniteTuple { annotation = actual; _ }; _ }) (ListVariadicVariable { mismatch = NotDefiniteTuple { annotation = actual; _ }; _ })
| InvalidException { annotation = actual; _ } | InvalidException { annotation = actual; _ }
| InvalidType (InvalidType { annotation = actual; _ }) | InvalidType (InvalidType { annotation = actual; _ })
| InvalidType (FinalNested actual) | InvalidType (FinalNested actual)
| NotCallable actual | NotCallable actual
| ProhibitedAny { missing_annotation = { given_annotation = Some actual; _ }; _ } | ProhibitedAny { missing_annotation = { given_annotation = Some actual; _ }; _ }
| RedundantCast actual | RedundantCast actual
| UninitializedAttribute { mismatch = { actual; _ }; _ } | UninitializedAttribute { mismatch = { actual; _ }; _ }
| Unpack { unpack_problem = UnacceptableType actual; _ } -> | Unpack { unpack_problem = UnacceptableType actual; _ } ->
is_due_to_analysis_limitations actual is_due_to_analysis_limitations actual
| IncompatibleParameterType (Operand { left_operand; right_operand; _ }) -> | UnsupportedOperand (Binary { left_operand; right_operand; _ }) ->
is_due_to_analysis_limitations left_operand || is_due_to_analysis_limitati ons right_operand is_due_to_analysis_limitations left_operand || is_due_to_analysis_limitati ons right_operand
| UnsupportedOperand (Unary { operand; _ }) -> is_due_to_analysis_limitations operand
| Top -> true | Top -> true
| UndefinedAttribute { origin = Class annotation; _ } -> Type.contains_unknown annotation | UndefinedAttribute { origin = Class annotation; _ } -> Type.contains_unknown annotation
| AnalysisFailure _ | AnalysisFailure _
| ParserFailure _ | ParserFailure _
| DeadStore _ | DeadStore _
| Deobfuscation _ | Deobfuscation _
| IllegalAnnotationTarget _ | IllegalAnnotationTarget _
| IncompatibleAsyncGeneratorReturnType _ | IncompatibleAsyncGeneratorReturnType _
| IncompatibleConstructorAnnotation _ | IncompatibleConstructorAnnotation _
| InconsistentOverride { override = StrengthenedPrecondition (NotFound _); _ } | InconsistentOverride { override = StrengthenedPrecondition (NotFound _); _ }
skipping to change at line 2370 skipping to change at line 2386
| DeadStore left, DeadStore right -> Identifier.equal left right | DeadStore left, DeadStore right -> Identifier.equal left right
| Deobfuscation left, Deobfuscation right -> Source.equal left right | Deobfuscation left, Deobfuscation right -> Source.equal left right
| IllegalAnnotationTarget left, IllegalAnnotationTarget right -> Expression.eq ual left right | IllegalAnnotationTarget left, IllegalAnnotationTarget right -> Expression.eq ual left right
| ImpossibleAssertion left, ImpossibleAssertion right when Expression.equal le ft.test right.test | ImpossibleAssertion left, ImpossibleAssertion right when Expression.equal le ft.test right.test
-> ->
GlobalResolution.less_or_equal resolution ~left:left.annotation ~right:rig ht.annotation GlobalResolution.less_or_equal resolution ~left:left.annotation ~right:rig ht.annotation
| IncompatibleAsyncGeneratorReturnType left, IncompatibleAsyncGeneratorReturnT ype right -> | IncompatibleAsyncGeneratorReturnType left, IncompatibleAsyncGeneratorReturnT ype right ->
GlobalResolution.less_or_equal resolution ~left ~right GlobalResolution.less_or_equal resolution ~left ~right
| IncompatibleAwaitableType left, IncompatibleAwaitableType right -> | IncompatibleAwaitableType left, IncompatibleAwaitableType right ->
GlobalResolution.less_or_equal resolution ~left ~right GlobalResolution.less_or_equal resolution ~left ~right
| ( IncompatibleParameterType | IncompatibleParameterType left, IncompatibleParameterType right
(Operand
{
operator_name = left_operator_name;
left_operand = left_operand_for_left;
right_operand = right_operand_for_left;
}),
IncompatibleParameterType
(Operand
{
operator_name = right_operator_name;
left_operand = left_operand_for_right;
right_operand = right_operand_for_right;
}) )
when Identifier.equal_sanitized left_operator_name right_operator_name ->
GlobalResolution.less_or_equal
resolution
~left:left_operand_for_left
~right:left_operand_for_right
&& GlobalResolution.less_or_equal
resolution
~left:right_operand_for_left
~right:right_operand_for_right
| IncompatibleParameterType (Argument left), IncompatibleParameterType (Argume
nt right)
when Option.equal Identifier.equal_sanitized left.name right.name -> when Option.equal Identifier.equal_sanitized left.name right.name ->
less_or_equal_mismatch left.mismatch right.mismatch less_or_equal_mismatch left.mismatch right.mismatch
| IncompatibleConstructorAnnotation left, IncompatibleConstructorAnnotation ri ght -> | IncompatibleConstructorAnnotation left, IncompatibleConstructorAnnotation ri ght ->
GlobalResolution.less_or_equal resolution ~left ~right GlobalResolution.less_or_equal resolution ~left ~right
| IncompatibleReturnType left, IncompatibleReturnType right -> | IncompatibleReturnType left, IncompatibleReturnType right ->
less_or_equal_mismatch left.mismatch right.mismatch less_or_equal_mismatch left.mismatch right.mismatch
| IncompatibleOverload left, IncompatibleOverload right -> ( | IncompatibleOverload left, IncompatibleOverload right -> (
match left, right with match left, right with
| ReturnType left, ReturnType right -> | ReturnType left, ReturnType right ->
Type.equal left.implementation_annotation right.implementation_annotat ion Type.equal left.implementation_annotation right.implementation_annotat ion
skipping to change at line 2571 skipping to change at line 2564
when Identifier.equal_sanitized left.attribute right.attribute -> ( when Identifier.equal_sanitized left.attribute right.attribute -> (
match left.origin, right.origin with match left.origin, right.origin with
| Class left, Class right -> GlobalResolution.less_or_equal resolution ~le ft ~right | Class left, Class right -> GlobalResolution.less_or_equal resolution ~le ft ~right
| Module left, Module right -> Reference.equal_sanitized left right | Module left, Module right -> Reference.equal_sanitized left right
| _ -> false ) | _ -> false )
| UndefinedType left, UndefinedType right -> Type.equal left right | UndefinedType left, UndefinedType right -> Type.equal left right
| UnexpectedKeyword left, UnexpectedKeyword right -> | UnexpectedKeyword left, UnexpectedKeyword right ->
Option.equal Reference.equal_sanitized left.callee right.callee Option.equal Reference.equal_sanitized left.callee right.callee
&& Identifier.equal left.name right.name && Identifier.equal left.name right.name
| UndefinedImport left, UndefinedImport right -> [%compare.equal: undefined_im port] left right | UndefinedImport left, UndefinedImport right -> [%compare.equal: undefined_im port] left right
| ( UnsupportedOperand
(Binary
{
operator_name = left_operator_name;
left_operand = left_operand_for_left;
right_operand = right_operand_for_left;
}),
UnsupportedOperand
(Binary
{
operator_name = right_operator_name;
left_operand = left_operand_for_right;
right_operand = right_operand_for_right;
}) )
when Identifier.equal_sanitized left_operator_name right_operator_name ->
GlobalResolution.less_or_equal
resolution
~left:left_operand_for_left
~right:left_operand_for_right
&& GlobalResolution.less_or_equal
resolution
~left:right_operand_for_left
~right:right_operand_for_right
| ( UnsupportedOperand (Unary { operator_name = left_operator_name; operand =
left_operand }),
UnsupportedOperand (Unary { operator_name = right_operator_name; operand =
right_operand }) )
when Identifier.equal_sanitized left_operator_name right_operator_name ->
GlobalResolution.less_or_equal resolution ~left:left_operand ~right:right_
operand
| UnusedIgnore left, UnusedIgnore right -> | UnusedIgnore left, UnusedIgnore right ->
IntSet.is_subset (IntSet.of_list left) ~of_:(IntSet.of_list right) IntSet.is_subset (IntSet.of_list left) ~of_:(IntSet.of_list right)
| ( UnusedLocalMode { unused_mode = left_unused_mode; actual_mode = left_actua l_mode }, | ( UnusedLocalMode { unused_mode = left_unused_mode; actual_mode = left_actua l_mode },
UnusedLocalMode { unused_mode = right_unused_mode; actual_mode = right_act ual_mode } ) -> UnusedLocalMode { unused_mode = right_unused_mode; actual_mode = right_act ual_mode } ) ->
Source.equal_local_mode left_unused_mode.Node.value right_unused_mode.Node .value Source.equal_local_mode left_unused_mode.Node.value right_unused_mode.Node .value
&& Source.equal_local_mode left_actual_mode.Node.value right_actual_mode.N ode.value && Source.equal_local_mode left_actual_mode.Node.value right_actual_mode.N ode.value
| ( Unpack { expected_count = left_count; unpack_problem = left_problem }, | ( Unpack { expected_count = left_count; unpack_problem = left_problem },
Unpack { expected_count = right_count; unpack_problem = right_problem } ) -> ( Unpack { expected_count = right_count; unpack_problem = right_problem } ) -> (
left_count = right_count left_count = right_count
&& &&
skipping to change at line 2644 skipping to change at line 2664
| TypedDictionaryInitializationError _, _ | TypedDictionaryInitializationError _, _
| TypedDictionaryKeyNotFound _, _ | TypedDictionaryKeyNotFound _, _
| UnawaitedAwaitable _, _ | UnawaitedAwaitable _, _
| UnboundName _, _ | UnboundName _, _
| UndefinedAttribute _, _ | UndefinedAttribute _, _
| UndefinedImport _, _ | UndefinedImport _, _
| UndefinedType _, _ | UndefinedType _, _
| UnexpectedKeyword _, _ | UnexpectedKeyword _, _
| UninitializedAttribute _, _ | UninitializedAttribute _, _
| Unpack _, _ | Unpack _, _
| UnsupportedOperand _, _
| UnusedIgnore _, _ | UnusedIgnore _, _
| UnusedLocalMode _, _ -> | UnusedLocalMode _, _ ->
false false
let join ~resolution left right = let join ~resolution left right =
let join_mismatch left right = let join_mismatch left right =
{ {
expected = GlobalResolution.join resolution left.expected right.expected; expected = GlobalResolution.join resolution left.expected right.expected;
actual = GlobalResolution.join resolution left.actual right.actual; actual = GlobalResolution.join resolution left.actual right.actual;
due_to_invariance = left.due_to_invariance || right.due_to_invariance; due_to_invariance = left.due_to_invariance || right.due_to_invariance;
skipping to change at line 2774 skipping to change at line 2795
{ {
expression = left_expression; expression = left_expression;
annotation = annotation =
{ {
Annotation.annotation = Annotation.annotation =
GlobalResolution.join resolution left_annotation right_annotat ion; GlobalResolution.join resolution left_annotation right_annotat ion;
mutability = left_mutability; mutability = left_mutability;
}; };
qualify = left_qualify || right_qualify (* lol *); qualify = left_qualify || right_qualify (* lol *);
} }
| ( IncompatibleParameterType | IncompatibleParameterType left, IncompatibleParameterType right
(Operand
( {
operator_name = left_operator_name;
left_operand = left_operand_for_left;
right_operand = right_operand_for_left;
} as left )),
IncompatibleParameterType
(Operand
{
operator_name = right_operator_name;
left_operand = left_operand_for_right;
right_operand = right_operand_for_right;
}) )
when Identifier.equal_sanitized left_operator_name right_operator_name ->
IncompatibleParameterType
(Operand
{
left with
left_operand =
GlobalResolution.join resolution left_operand_for_left left_ope
rand_for_right;
right_operand =
GlobalResolution.join resolution right_operand_for_left right_o
perand_for_right;
})
| IncompatibleParameterType (Argument left), IncompatibleParameterType (Argu
ment right)
when Option.equal Identifier.equal_sanitized left.name right.name when Option.equal Identifier.equal_sanitized left.name right.name
&& left.position = right.position && left.position = right.position
&& Option.equal Reference.equal_sanitized left.callee right.callee -> && Option.equal Reference.equal_sanitized left.callee right.callee ->
let mismatch = join_mismatch left.mismatch right.mismatch in let mismatch = join_mismatch left.mismatch right.mismatch in
IncompatibleParameterType (Argument { left with mismatch }) IncompatibleParameterType { left with mismatch }
| IncompatibleConstructorAnnotation left, IncompatibleConstructorAnnotation right -> | IncompatibleConstructorAnnotation left, IncompatibleConstructorAnnotation right ->
IncompatibleConstructorAnnotation (GlobalResolution.join resolution left right) IncompatibleConstructorAnnotation (GlobalResolution.join resolution left right)
| IncompatibleReturnType left, IncompatibleReturnType right -> | IncompatibleReturnType left, IncompatibleReturnType right ->
IncompatibleReturnType IncompatibleReturnType
{ {
mismatch = join_mismatch left.mismatch right.mismatch; mismatch = join_mismatch left.mismatch right.mismatch;
is_implicit = left.is_implicit && right.is_implicit; is_implicit = left.is_implicit && right.is_implicit;
is_unimplemented = left.is_unimplemented && right.is_unimplemented; is_unimplemented = left.is_unimplemented && right.is_unimplemented;
define_location = right.define_location; define_location = right.define_location;
} }
skipping to change at line 2926 skipping to change at line 2923
&& Reference.equal_sanitized left right -> && Reference.equal_sanitized left right ->
UndefinedAttribute { origin = Module left; attribute = left_attribute } UndefinedAttribute { origin = Module left; attribute = left_attribute }
| UndefinedType left, UndefinedType right when Type.equal left right -> Unde finedType left | UndefinedType left, UndefinedType right when Type.equal left right -> Unde finedType left
| UnexpectedKeyword left, UnexpectedKeyword right | UnexpectedKeyword left, UnexpectedKeyword right
when Option.equal Reference.equal_sanitized left.callee right.callee when Option.equal Reference.equal_sanitized left.callee right.callee
&& Identifier.equal left.name right.name -> && Identifier.equal left.name right.name ->
UnexpectedKeyword left UnexpectedKeyword left
| UndefinedImport left, UndefinedImport right when [%compare.equal: undefine d_import] left right | UndefinedImport left, UndefinedImport right when [%compare.equal: undefine d_import] left right
-> ->
UndefinedImport left UndefinedImport left
| ( UnsupportedOperand
(Binary
( {
operator_name = left_operator_name;
left_operand = left_operand_for_left;
right_operand = right_operand_for_left;
} as left )),
UnsupportedOperand
(Binary
{
operator_name = right_operator_name;
left_operand = left_operand_for_right;
right_operand = right_operand_for_right;
}) )
when Identifier.equal_sanitized left_operator_name right_operator_name ->
UnsupportedOperand
(Binary
{
left with
left_operand =
GlobalResolution.join resolution left_operand_for_left left_ope
rand_for_right;
right_operand =
GlobalResolution.join resolution right_operand_for_left right_o
perand_for_right;
})
| ( UnsupportedOperand
(Unary ({ operator_name = left_operator_name; operand = left_operand }
as left)),
UnsupportedOperand (Unary { operator_name = right_operator_name; operand
= right_operand })
)
when Identifier.equal_sanitized left_operator_name right_operator_name ->
UnsupportedOperand
(Unary { left with operand = GlobalResolution.join resolution left_ope
rand right_operand })
| UnusedIgnore left, UnusedIgnore right -> | UnusedIgnore left, UnusedIgnore right ->
UnusedIgnore (IntSet.to_list (IntSet.union (IntSet.of_list left) (IntSet .of_list right))) UnusedIgnore (IntSet.to_list (IntSet.union (IntSet.of_list left) (IntSet .of_list right)))
| ( Unpack { expected_count = left_count; unpack_problem = UnacceptableType left }, | ( Unpack { expected_count = left_count; unpack_problem = UnacceptableType left },
Unpack { expected_count = right_count; unpack_problem = UnacceptableType right } ) Unpack { expected_count = right_count; unpack_problem = UnacceptableType right } )
when left_count = right_count -> when left_count = right_count ->
Unpack Unpack
{ {
expected_count = left_count; expected_count = left_count;
unpack_problem = UnacceptableType (GlobalResolution.join resolution left right); unpack_problem = UnacceptableType (GlobalResolution.join resolution left right);
} }
skipping to change at line 3045 skipping to change at line 3073
| TypedDictionaryInvalidOperation _, _ | TypedDictionaryInvalidOperation _, _
| TypedDictionaryInitializationError _, _ | TypedDictionaryInitializationError _, _
| UnawaitedAwaitable _, _ | UnawaitedAwaitable _, _
| UnboundName _, _ | UnboundName _, _
| UndefinedAttribute _, _ | UndefinedAttribute _, _
| UndefinedImport _, _ | UndefinedImport _, _
| UndefinedType _, _ | UndefinedType _, _
| UnexpectedKeyword _, _ | UnexpectedKeyword _, _
| UninitializedAttribute _, _ | UninitializedAttribute _, _
| Unpack _, _ | Unpack _, _
| UnsupportedOperand _, _
| UnusedIgnore _, _ | UnusedIgnore _, _
| UnusedLocalMode _, _ -> | UnusedLocalMode _, _ ->
let { location; _ } = left in let { location; _ } = left in
Log.debug Log.debug
"Incompatible type in error join at %a: %a %a" "Incompatible type in error join at %a: %a %a"
Location.WithModule.pp Location.WithModule.pp
location location
pp_kind pp_kind
left.kind left.kind
pp_kind pp_kind
skipping to change at line 3148 skipping to change at line 3177
let error_set = Hash_set.create ~size:(List.length errors) () in let error_set = Hash_set.create ~size:(List.length errors) () in
List.iter errors ~f:(Core.Hash_set.add error_set); List.iter errors ~f:(Core.Hash_set.add error_set);
Core.Hash_set.to_list error_set Core.Hash_set.to_list error_set
let filter ~resolution errors = let filter ~resolution errors =
let should_filter error = let should_filter error =
let is_mock_error { kind; _ } = let is_mock_error { kind; _ } =
match kind with match kind with
| IncompatibleAttributeType { incompatible_type = { mismatch = { actual; _ }; _ }; _ } | IncompatibleAttributeType { incompatible_type = { mismatch = { actual; _ }; _ }; _ }
| IncompatibleAwaitableType actual | IncompatibleAwaitableType actual
| IncompatibleParameterType (Argument { mismatch = { actual; _ }; _ }) | IncompatibleParameterType { mismatch = { actual; _ }; _ }
| IncompatibleReturnType { mismatch = { actual; _ }; _ } | IncompatibleReturnType { mismatch = { actual; _ }; _ }
| IncompatibleVariableType { incompatible_type = { mismatch = { actual; _ }; _ }; _ } | IncompatibleVariableType { incompatible_type = { mismatch = { actual; _ }; _ }; _ }
| TypedDictionaryInvalidOperation { mismatch = { actual; _ }; _ } | TypedDictionaryInvalidOperation { mismatch = { actual; _ }; _ }
| UndefinedAttribute { origin = Class actual; _ } -> | UndefinedAttribute { origin = Class actual; _ } ->
let is_subclass_of_mock annotation = let is_subclass_of_mock annotation =
try try
match annotation with match annotation with
| Type.Primitive predecessor | Type.Primitive predecessor
| Type.Parametric { name = predecessor; _ } -> | Type.Parametric { name = predecessor; _ } ->
let is_transitive_successor = let is_transitive_successor =
skipping to change at line 3193 skipping to change at line 3222
| MissingAttributeAnnotation { missing_annotation = { thrown_at_source; _ }; _ } -> | MissingAttributeAnnotation { missing_annotation = { thrown_at_source; _ }; _ } ->
not thrown_at_source not thrown_at_source
| _ -> false | _ -> false
in in
let is_unknown_callable_error { kind; _ } = let is_unknown_callable_error { kind; _ } =
(* TODO(T41494196): Remove when we have AnyCallable escape hatch. *) (* TODO(T41494196): Remove when we have AnyCallable escape hatch. *)
match kind with match kind with
| InconsistentOverride | InconsistentOverride
{ override = StrengthenedPrecondition (Found { expected; actual; _ }); _ } { override = StrengthenedPrecondition (Found { expected; actual; _ }); _ }
| InconsistentOverride { override = WeakenedPostcondition { expected; actu al; _ }; _ } | InconsistentOverride { override = WeakenedPostcondition { expected; actu al; _ }; _ }
| IncompatibleParameterType (Argument { mismatch = { expected; actual; _ } ; _ }) | IncompatibleParameterType { mismatch = { expected; actual; _ }; _ }
| IncompatibleReturnType { mismatch = { expected; actual; _ }; _ } | IncompatibleReturnType { mismatch = { expected; actual; _ }; _ }
| IncompatibleAttributeType | IncompatibleAttributeType
{ incompatible_type = { mismatch = { expected; actual; _ }; _ }; _ } { incompatible_type = { mismatch = { expected; actual; _ }; _ }; _ }
| TypedDictionaryInvalidOperation { mismatch = { expected; actual; _ }; _ } | TypedDictionaryInvalidOperation { mismatch = { expected; actual; _ }; _ }
| IncompatibleVariableType | IncompatibleVariableType
{ incompatible_type = { mismatch = { expected; actual; _ }; _ }; _ } - > ( { incompatible_type = { mismatch = { expected; actual; _ }; _ }; _ } - > (
match actual with match actual with
| Type.Callable _ -> | Type.Callable _ ->
GlobalResolution.less_or_equal GlobalResolution.less_or_equal
resolution resolution
skipping to change at line 3528 skipping to change at line 3557
{ {
current_class = dequalify_reference current_class; current_class = dequalify_reference current_class;
shadowed_class = dequalify_reference shadowed_class; shadowed_class = dequalify_reference shadowed_class;
is_shadowed_class_imported; is_shadowed_class_imported;
} }
| RedefinedClass redefined_class -> RedefinedClass redefined_class | RedefinedClass redefined_class -> RedefinedClass redefined_class
| RedundantCast annotation -> RedundantCast (dequalify annotation) | RedundantCast annotation -> RedundantCast (dequalify annotation)
| RevealedType { expression; annotation; qualify } -> | RevealedType { expression; annotation; qualify } ->
let annotation = if qualify then annotation else dequalify_annotation an notation in let annotation = if qualify then annotation else dequalify_annotation an notation in
RevealedType { expression; annotation; qualify } RevealedType { expression; annotation; qualify }
| IncompatibleParameterType (Operand { operator_name; left_operand; right_op erand }) -> | IncompatibleParameterType ({ mismatch; callee; _ } as parameter) ->
IncompatibleParameterType IncompatibleParameterType
(Operand {
{ parameter with
operator_name; mismatch = dequalify_mismatch mismatch;
left_operand = dequalify left_operand; callee = Option.map callee ~f:dequalify_reference;
right_operand = dequalify right_operand; }
})
| IncompatibleParameterType (Argument ({ mismatch; callee; _ } as parameter)
) ->
IncompatibleParameterType
(Argument
{
parameter with
mismatch = dequalify_mismatch mismatch;
callee = Option.map callee ~f:dequalify_reference;
})
| IncompatibleReturnType ({ mismatch; _ } as return) -> | IncompatibleReturnType ({ mismatch; _ } as return) ->
IncompatibleReturnType { return with mismatch = dequalify_mismatch misma tch } IncompatibleReturnType { return with mismatch = dequalify_mismatch misma tch }
| IncompatibleAttributeType { parent; incompatible_type = { mismatch; _ } as incompatible_type } | IncompatibleAttributeType { parent; incompatible_type = { mismatch; _ } as incompatible_type }
-> ->
IncompatibleAttributeType IncompatibleAttributeType
{ {
parent = dequalify parent; parent = dequalify parent;
incompatible_type = { incompatible_type with mismatch = dequalify_mi smatch mismatch }; incompatible_type = { incompatible_type with mismatch = dequalify_mi smatch mismatch };
} }
| IncompatibleVariableType ({ incompatible_type = { mismatch; _ }; _ } as va riable) -> | IncompatibleVariableType ({ incompatible_type = { mismatch; _ }; _ } as va riable) ->
skipping to change at line 3662 skipping to change at line 3682
dequalify annotation dequalify annotation
in in
Class annotation Class annotation
| Module module_name -> Module (dequalify_reference module_name) | Module module_name -> Module (dequalify_reference module_name)
in in
UndefinedAttribute { attribute; origin } UndefinedAttribute { attribute; origin }
| UndefinedType annotation -> UndefinedType (dequalify annotation) | UndefinedType annotation -> UndefinedType (dequalify annotation)
| UndefinedImport reference -> UndefinedImport reference | UndefinedImport reference -> UndefinedImport reference
| UnexpectedKeyword { name; callee } -> | UnexpectedKeyword { name; callee } ->
UnexpectedKeyword { name; callee = Option.map callee ~f:dequalify_refere nce } UnexpectedKeyword { name; callee = Option.map callee ~f:dequalify_refere nce }
| UnsupportedOperand (Binary { operator_name; left_operand; right_operand })
->
UnsupportedOperand
(Binary
{
operator_name;
left_operand = dequalify left_operand;
right_operand = dequalify right_operand;
})
| UnsupportedOperand (Unary { operator_name; operand }) ->
UnsupportedOperand (Unary { operator_name; operand = dequalify operand }
)
| MissingArgument { callee; parameter } -> | MissingArgument { callee; parameter } ->
MissingArgument { callee = Option.map callee ~f:dequalify_reference; par ameter } MissingArgument { callee = Option.map callee ~f:dequalify_reference; par ameter }
| ParserFailure failure -> ParserFailure failure | ParserFailure failure -> ParserFailure failure
| UnusedIgnore codes -> UnusedIgnore codes | UnusedIgnore codes -> UnusedIgnore codes
| UnusedLocalMode mode -> UnusedLocalMode mode | UnusedLocalMode mode -> UnusedLocalMode mode
| Unpack unpack -> Unpack unpack | Unpack unpack -> Unpack unpack
in in
let signature = let signature =
let dequalify_parameter ({ Node.value; _ } as parameter) = let dequalify_parameter ({ Node.value; _ } as parameter) =
value.Expression.Parameter.annotation value.Expression.Parameter.annotation
 End of changes. 27 change blocks. 
109 lines changed or deleted 145 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)