在任何项目中查找并修复您的导入周期
项目描述
Pycycle是一个实验项目,旨在帮助 python 开发人员解决循环依赖问题。
ImportError: Cannot import name X是一个与循环导入相关的 python 异常,但该异常没有说明在哪里或什么。
此工具会自动分析项目的导入,并查找可能导致循环依赖问题的导入。
特征
向您展示循环导入的整个链。
为您提供每次导入所在的代码行,以便您轻松找到并解决问题。
在图表中可视化您的导入(尚未实现)
用法
$ pycycle Usage: pycycle [OPTIONS] COMMAND [ARGS]... Examples: Get the circular imports in current project: $ pycycle --here Look for circular imports in another project $ pycycle --source /home/user/workspace/awesome_project Ignore specific directories when looking for circular import $ pycycle --source /home/user/workspace/awesome_project --ignore some_dir,some_dir2 Get verbose output $ pycycle --source /home/user/workspace/awesome_project --verbose Options: --verbose Verbose output. --here Try to find cycles in the current project. --source TEXT Try to find cycles in the path provided. --ignore TEXT Comma separated directories that will be ignored during analysis. --encoding TEXT Change enconding with which the project is read. --help Show this message then exit. --version Show the version and exit.
$ pycycle --here Project successfully transformed to AST, checking imports for cycles.. Cycle Found :( a_module.a_file: Line 1 -> a_module.b_module.b_file: Line 1 -> c_module.c_file: Line 1 -> d_module.d_file: Line 1 =>> a_module.a_file Finished.
$ pycycle --source /Users/vkravcenko/workspace/awesome_project Target source provided:/Users/vkravcenko/workspace/awesome_project Project successfully transformed to AST, checking imports for cycles.. No worries, no cycles here! If you think some cycle was missed, please open an Issue on Github. Finished.
安装
$ pip install pycycle
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
pycycle-0.0.8.tar.gz
(5.8 kB
查看哈希)
内置分布
pycycle-0.0.8-py2-none-any.whl
(8.7 kB
查看哈希)