简体   繁体   English

删除未使用的库 python pyproject.toml

[英]Remove unused libraries python pyproject.toml

I am using pyproject.toml to organize my python venv and later create environments with poetry from it.我正在使用 pyproject.toml 来组织我的 python venv,然后用它创建带有诗歌的环境。

However, over time more and more libraries have been added as a dependency but some are not used any more in the code.然而,随着时间的推移,越来越多的库被添加为依赖项,但有些库不再在代码中使用。

What's the best/easiest way to find out which dependencies can be deleted without breaking anything?找出可以在不破坏任何东西的情况下删除哪些依赖项的最佳/最简单方法是什么? I am thinking VSCode plugin, pip-package that analyzes python files in a directory, ...我在想 VSCode 插件,pip-package 分析目录中的 python 文件,...

You could use AST to get all import statements by navigating all the paths, then use tomlkit to read pyproject.toml file.您可以使用 AST 通过导航所有路径来获取所有导入语句,然后使用 tomlkit 读取 pyproject.toml 文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM