APIScanner --自动检测Python库中不推荐的API
APIScanner -- Towards Automated Detection of Deprecated APIs in Python Libraries
摘要:
Python库广泛用于机器学习和科学计算任务。Python库中的API由于功能增强和错误修复而被弃用,与其他语言相同。不鼓励在进一步的软件开发中使用这些弃用的API。由于项目中使用了大量的API调用,手动检测和替换弃用的API是一项繁琐且耗时的任务。此外,缺乏适当的文档,这些弃用的API使任务具有挑战性。为了应对这一挑战,我们提出了一种算法和工具APIScanner,可以自动检测Python库中的弃用API。该算法使用抽象语法树(AST)解析库的源代码,并通过装饰器,硬编码警告或注释来识别弃用的API。APIScanner是一个Visual Studio代码扩展,它在编写源代码时突出显示并警告开发人员使用不推荐使用的API元素。该工具可以帮助开发人员避免在不执行代码的情况下使用已弃用的API元素。我们在六个流行的Python库上测试了我们的算法和工具,检测到871个弃用的API元素中的838个。APIScanner演示:https://youtu.be/1hy_ugf-iek。文档、工具和源代码可以在这里找到:https://rishitha957.github.io/APIScanner。
英文摘要:
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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。