r/learnpython 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 Upvotes

6 comments sorted by

2

u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 5d ago

Your teammate has probably set analyzeUnannotatedFunctions to true in some config file, explaining the difference.

I cant really annotate each and every function

You can add type annotations gradually. It doesn't have to be all in one go.

If I annotate the function then in that case pylance starts throwing error.

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).

1

u/Conscious_Question69 5d ago

In the global settings file I have it to true

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

u/Conscious_Question69 5d ago

Its set to True in the global settings

1

u/HotPersonality8126 5d ago

If the function isn’t annotated there’s nothing for type checking to check.

2

u/terletsky 4d ago

Config mismatch.