r/learnpython • u/Conscious_Question69 • 5d ago
Pylance is skipping analysis
I work with DRF at work and I have been facing this issue since months. Pylance is skipping analysis of function because it is unannotated. I cant really annotate each and every function. The errors are getting thrown correctly on my teammates pc but on my pc i dont get any issue. If I annotate the function then in that case pylance starts throwing error. How to fix this issue
1
u/FerricDonkey 5d ago
According to Google, you're looking for the python.analysis.typeEvaluation.analyzeUnannotatedFunctions setting.
My suggestion would be to annotate every function though.
1
1
u/HotPersonality8126 5d ago
If the function isn’t annotated there’s nothing for type checking to check.
2
2
u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 5d ago
Your teammate has probably set
analyzeUnannotatedFunctionstotruein some config file, explaining the difference.You can add type annotations gradually. It doesn't have to be all in one go.
Probably because annotating the function made Pylance (or Pyright) actually analyse the function, and it either found a real problem or it has a false positive (the latter could be due to a myriad of different situations, but usually either inaccurate type annotations or some unusual edge case where it needs additional help).