SMAT-Lab / Scalpel

Scalpel: The Python Static Analysis Framework
Apache License 2.0
286 stars 43 forks source link

Error in analyzers.py #18

Closed Andres981231 closed 2 years ago

Andres981231 commented 2 years ago

When I try to run type_infer_tutorial.py in the examples, I got the error "AttributeError: module 'typed_ast' has no attribute '_ast3'" which is caused by typeinfer/analysers.py at line 150. I wonder whether this is a bug in the development? Thanks!

Andres981231 commented 2 years ago

Should add "from typed_ast import _ast3" in type_infer_tutorial.py.

Jarvx commented 2 years ago

Hi,

Thanks for pointing this out. Could you please let us know your environment information as we cannot reproduce this error?

Andres981231 commented 2 years ago

I manually install Scalpel with setup.py instead of pip, and tested on both windows10 and ubuntu18.04, with python version 3.7.0, both produced this error.

Andres981231 commented 2 years ago

I also wonder whether the type inference functionbility will consider the import module of a python program. Since in my local test, for code piece "A = (a class from imported module)", the variable A's type was inferred as "Any".

Jarvx commented 2 years ago

Thanks for the information to reproduce the error. Regarding the given test case, at this stage, we do not consider it as a type because the imported names such as "from A import B" might not be a class. "B" can be a module name instead. We are still working on better algorithms for type inference. Thanks a lot for raising this issue.