Python libraries are widely used for machine learning and scientific computing tasks today. APIs in Python libraries are deprecated due to feature enhancements and bug fixes in the same way as in other languages. These deprecated APIs are discouraged from being used in further software development. Manually detecting and replacing deprecated APIs is a tedious and time-consuming task due to the large number of API calls used in the projects. Moreover, the lack of proper documentation for these deprecated APIs makes the task challenging. To address this challenge, we propose an algorithm and a tool APIScanner that automatically detects deprecated APIs in Python libraries. This algorithm parses the source code of the libraries using abstract syntax tree (ASTs) and identifies the deprecated APIs via decorator, hard-coded warning or comments. APIScanner is a Visual Studio Code Extension that highlights and warns the developer on the use of deprecated API elements while writing the source code. The tool can help developers to avoid using deprecated API elements without the execution of code. We tested our algorithm and tool on six popular Python libraries, which detected 838 of 871 deprecated API elements. Demo of APIScanner: https://youtu.be/1hy_ugf-iek. Documentation, tool, and source code can be found here: https://rishitha957.github.io/APIScanner.
翻译:Python 图书馆广泛用于机器学习和科学计算任务; Python 图书馆的API由于功能增强和错误修正而退化; 这些被损坏的API 无法用于软件的进一步开发; 人工检测和替换被损坏的API是一个乏味和耗时的任务,原因是项目中使用了大量的API电话; 此外,这些被损坏的API 缺乏适当的文件使任务具有挑战性; 为了应对这一挑战,我们建议了一种算法和一个工具APIScanner,该算法和工具可以自动检测Python 图书馆中被损坏的APIS 。 这个算法用抽象的合成树(ASTs)来分析图书馆的源代码,并查明了被损坏的API, 硬编码警告或评论。 APIS Canner 是一个视觉工作室代码扩展,可以突出和警告开发者使用被损坏的 API 要素,同时写入源代码。 工具可以帮助开发者在不使用我们内部的 API IMIS 中检测到的 6- decread AS 。