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

pylint fails on relative import in tests directories #758

Closed
toumorokoshi opened this issue May 30, 2020 · 2 comments
Closed

pylint fails on relative import in tests directories #758

toumorokoshi opened this issue May 30, 2020 · 2 comments

Comments

@toumorokoshi
Copy link
Member

the relative imports in test directories fails with multiple tests/ directories, because a single init.py declares it as a regular namespace vs a package namespace:

https://packaging.python.org/guides/packaging-namespace-packages/#packaging-namespace-packages

Removing the init.py is the correct approach, as this makes the directory a namespace package, implicitly. However, pylint doesn't support namespace packages and relative imports:

pylint-dev/pylint#3609

For now I'm adding a workaround as stated here:

https://github.com/open-telemetry/opentelemetry-python/pull/727/files#diff-82f1c01233a504767e8c3f22a70b5940R22

But long term, we should either

  1. put the workaround in all init.py in tests directories, which will ensure the workaround works regardless of which tests directory is found on the path first.

Or

  1. once the pylint bug is fixed, removing the init.py from all test files, which is the best practice as of PEP 420.
@toumorokoshi toumorokoshi added this to the Technical Debt milestone May 30, 2020
@github-actions
Copy link

github-actions bot commented Apr 9, 2021

This issue was marked stale due to lack of activity. It will be closed in 30 days.

@github-actions
Copy link

github-actions bot commented Jun 8, 2021

Closed as inactive. Feel free to reopen if this issue needs resolving.

@github-actions github-actions bot closed this as completed Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant