VSCode - Call to undefined function in imported module

Viewed 43

If I write this code:

import math
math.abcdef()

where clearly the method abcdef() does not exist in the imported math module, why doesn't visual studio code show an error?

Is there a way to force vscode to check that the called method exists in the imported module?

1 Answers

Such error messages in vscode are generally provided by linting.

You can enable linting in settings. The error messages obtained by selecting different linter are not exactly the same.

enter image description here

If you don't want use linting, change the python.analysis.typeCheckingMode option in the settings to basic or strict.

enter image description here

At this point, the Python extension prompts an error message.

enter image description here basic

enter image description here strict

Related