Skip to content

Commit

Permalink
Rename function, type_inside_typeguard
Browse files Browse the repository at this point in the history
Summary:
I didn't find `typeguard_annotation` to be a very descriptive name,
especially inside of the `Type` module which has tons of helpers that
do various things (often they *construct* a type, and as a result the old
name kind of sounded like it was a smart constructor which it isn't, it's
actually deconstructing)

Reviewed By: grievejia

Differential Revision: D59594270

fbshipit-source-id: 5e967e53087365505336d01835a946a384e80beb
  • Loading branch information
stroxler authored and facebook-github-bot committed Jul 11, 2024
1 parent 96eb62e commit 4e82c37
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion source/analysis/type.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4581,7 +4581,7 @@ let expression_contains_any expression =
|> List.exists ~f:(Hashtbl.mem primitives_with_any_map)


let typeguard_annotation = function
let type_inside_typeguard = function
| Parametric
{
name = "typing.TypeGuard" | "typing_extensions.TypeGuard";
Expand Down
2 changes: 1 addition & 1 deletion source/analysis/type.mli
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ val is_untyped : t -> bool

val contains_variable : t -> bool

val typeguard_annotation : t -> t option
val type_inside_typeguard : t -> t option

val parameters : t -> Parameter.t list option

Expand Down
2 changes: 1 addition & 1 deletion source/analysis/typeCheck.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4156,7 +4156,7 @@ module State (Context : Context) = struct
{ arguments = { Call.Argument.name = None; value = { Node.value = Name name; _ } } :: _; _ }
when is_simple_name name -> (
let { TypeInfo.Unit.annotation = callee_type; _ } = resolve_expression ~resolution test in
match Type.typeguard_annotation callee_type with
match Type.type_inside_typeguard callee_type with
| Some guard_type ->
let resolution = refine_local ~name (TypeInfo.Unit.create_mutable guard_type) in
Value resolution
Expand Down

0 comments on commit 4e82c37

Please sign in to comment.