-
- Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Current problem
I want an argument/config option to disable sys.path patching. Pylint currently modifies sys.path based on __init__.py in folders of the linted files. sys.path patching is messy to get right and current logic for it here has a bug for implicit namespace packages that has been open for years. As a side effect a simple package structure of,
foo/ --> A.py bar/ --> foo/ ------> A.py where bar is a namespace package breaks if you try to lint both foo.A and bar.foo.A together.
While making implicit namespace packages work with sys.path patching is probably possible, sys.path patching means files are linted in a way different than actual execution of those imports in interpreter. You can have a folder pass because of patching, but running script would fail from that location if uninstalled.
A related issue is importing files in two separate packages sharing a name like in this issue is incompatible with current sys.path patching. Any solution for that issue will involve either not patching sys.path or patching more selectively.
Desired solution
Support a config argument/command line argument to disable patching. The current patch logic is only done in two places here and here. An option to disable it entirely would be a small patch to pylint. I'd be happy to make the patch if this change would be supported.
Additional context
No response