ITADN

Remove star imports from init modules

#39ClosedMArpogaus 创建于 2024-02-01
enhancement
M
MArpogauscommented
### Description Hello @francois-rozet, This should take up our discussion on the usage of star imports in #38: Using star imports in Python is very convenient and saves you from typing long module names repeatedly if you need to use multiple entities from a module. However, from my experience, star imports can cause naming conflicts if two modules have entities with the same name. Importing everything from a module can make it difficult to determine which specific entities are being used in the code. This can make code more error-prone and harder to debug. Additionally, Linters like ruff cant warn you about unused imports when start imports are used. Hence, I would suggest removing them from the init modules for the reasons mentioned above, at the cost of slightly higher maintenance. ### Implementation I did originally eliminate the use of all start import in commit [08d3f43](https://github.com/MArpogaus/zuko/commit/08d3f43801f693247a04b0695b7e04e4fa54ec88). If desired, I could cherry-pick `zuko/flows/__init__.py` from commit [08d3f43](https://github.com/MArpogaus/zuko/commit/08d3f43801f693247a04b0695b7e04e4fa54ec88) and remove the ignores from `pyprojetc.toml` in a new PR. ### Alternatives Leave everything as it is now.
关闭于 2024-06-06 2 条评论