Is there any way to disable "useImportHeuristic"? #3708
Replies: 5 comments
-
There's currently no way to disable this behavior. Whey you say it "confuses you", what do you mean? Pylance will always attempt to resolve the import first based on import resolution paths configured in your Python environment (the Is this behavior leading to false negatives in your code base? Or how else do you find the behavior confusing or undesirable? |
Beta Was this translation helpful? Give feedback.
-
yeah, as i said, "I am working on a big python project", so there could be hundreds of .py files and the working tree is sort of complicated. for example:
The |
Beta Was this translation helpful? Give feedback.
-
I'd prefer not to expose a configuration knob to control this behavior, but that's an option if this turns out to be a common enough request. I recommend moving this to the discussion forum to see what additional feedback we receive from other pylance users. |
Beta Was this translation helpful? Give feedback.
-
Moving this issue to discussion as an enhancement request for comments and upvotes. |
Beta Was this translation helpful? Give feedback.
-
I'd also like to be able to opt out of this behavior. I'm trying to help a team convert what was a loosely-organized directory full of Python files into a Python package. They're very used to being able to just import Pyright/Pylance are giving a false negative when checking files in the IDE and CLI, not giving an error on the This is especially glaring because Pyright will give an error if I typo an import name to something that's not available (ex: I read up on execution environments and import resolution. Neither mentions this [[tool.pyright.executionEnvironments]]
root = "." But no such luck. Given that the [[tool.pyright.executionEnvironments]]
root = "."
useImportHeuristics = false # preferably some better name for this. This would allow a single codebase to have both modules and script files in different paths. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am working on a big python project (a lot modules and only one main) and "resolving imports relative to each file" does confuse me when importing modules.
I found #253 which is the cause of it. Its seems that "useImportHeuristic" has been enabled by default:
Is there any way to disable it?
Beta Was this translation helpful? Give feedback.
All reactions