Skip to content

Commit

Permalink
[inferpython] bugfix the qualified name given to a module
Browse files Browse the repository at this point in the history
Summary: removing the / in the path. It helps with the Textual generation.

Reviewed By: geralt-encore

Differential Revision:
D64814008

Privacy Context Container: L1208441

fbshipit-source-id: 78581d42cef88e1f1e8514e83d4b353f9f5fdcbe
  • Loading branch information
davidpichardie authored and facebook-github-bot committed Oct 23, 2024
1 parent 54dd97e commit 3b2ff36
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion infer/src/python/PyIR.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2606,7 +2606,7 @@ let file_path {FFI.Code.co_filename} =
String.sub co_filename ~pos:2 ~len:(sz - 2)
else co_filename
in
Stdlib.Filename.remove_extension file_path
Stdlib.Filename.remove_extension file_path |> String.substr_replace_all ~pattern:"/" ~with_:"::"


let mk ~debug code =
Expand Down
16 changes: 15 additions & 1 deletion infer/src/python/unit/PyIRTestImport.ml
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ path.X()
PyIR.test ~filename:"some/long/path/dummy.py" source ;
[%expect
{|
module some/long/path/dummy:
module some::long::path::dummy:

function toplevel():
b0:
Expand All @@ -292,6 +292,20 @@ path.X()
return None |}]


let%expect_test _ =
let source = {|
pass
|} in
PyIR.test ~filename:"./dir1/dir2/script.py" source ;
[%expect
{|
module dir1::dir2::script:

function toplevel():
b0:
return None |}]


let%expect_test _ =
let source =
{|
Expand Down

0 comments on commit 3b2ff36

Please sign in to comment.