Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Do not remove explicitly re-exported imports even if unused #205

Open
gandhis1 opened this issue Jun 22, 2023 · 0 comments
Open
Labels
enhancement New feature or request feature New things

Comments

@gandhis1
Copy link

gandhis1 commented Jun 22, 2023

Mypy will prevent users from doing implicit re-exports. So if in module a you do from b import obj, and attempt to do from a import obj elsewhere, that will error. See https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-no-implicit-reexport for more context.

There are two ways in which you can explicitly re-export. They are:

  1. When you import and set the __all__ attribute in an __init__.py. pycln as far as I remember has no problem with this.
  2. When you use the explicit re-export syntax that is supported by Mypy, which is from b import obj as obj. This signals to Mypy that you are intentionally, deliberately re-exporting this, and are permitting imports of obj through module a.

It appears that 2 is not respected by pycln. It will remove these re-exports, because they are unused. So the feature request here is that pycln respects this convention and does not remove these. I understand that these are easily silenced through the comment directives, but the ask here is to make that superfluous.

@gandhis1 gandhis1 added enhancement New feature or request feature New things labels Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature New things
Projects
None yet
Development

No branches or pull requests

1 participant