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

Forbid self import #699

Closed
sobolevn opened this issue Jul 21, 2019 · 1 comment
Closed

Forbid self import #699

sobolevn opened this issue Jul 21, 2019 · 1 comment
Labels
help wanted Extra attention is needed level:starter Good for newcomers rule request Adding a new rule

Comments

@sobolevn
Copy link
Member

Rule request

Thesis

Modules can actually import self. Like this:

# ex.py
import ex

print(ex)

Running:

» python ex.py
<module 'ex' from '/Users/sobolev/Documents/github/wemake-python-styleguide/ex.py'>
<module 'ex' from '/Users/sobolev/Documents/github/wemake-python-styleguide/ex.py'>

Reasoning

This is useless and can be error-prone.
See import-self from http://pylint.pycqa.org/en/latest/technical_reference/features.html

@sobolevn sobolevn added help wanted Extra attention is needed level:starter Good for newcomers rule request Adding a new rule labels Jul 21, 2019
@sobolevn sobolevn added this to the Version 0.12.0 milestone Jul 21, 2019
@sobolevn sobolevn self-assigned this Jul 22, 2019
@sobolevn sobolevn removed this from the Version 0.12.0 milestone Jul 31, 2019
@sobolevn sobolevn removed their assignment Jul 31, 2019
@sobolevn
Copy link
Member Author

Some people use src/, some people patch PATH, some sys.modules.
We won't detect a lot of cases. Moreover, it is not a common mistake. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed level:starter Good for newcomers rule request Adding a new rule
Projects
None yet
Development

No branches or pull requests

1 participant