Class search is resulting in file located outside of conda environment

When I double shift and try to find the source of bytearray, PyCharm is taking me to the following location,

C:\Users\iamcr\AppData\Local\JetBrains\PyCharm2021.2\python_stubs\-154631607\builtins.py

I am using conda to manage my python environments. The active environment is in `py38` folder. For example, when I try to find the source of string class PyCharm takes me to,

C:\Users\iamcr\anaconda3\envs\py38\Lib\string.py

Which is where I expect string class to reside as py38 is the active python environment.

So, why PyCharm is taking me to builtins.py file that is not a part of my conda environment or py38 folder?

3 comments
Comment actions Permalink

Hi, could you please provide a code example to reproduce the issue?

0
Comment actions Permalink

I am just learning python and using IntellijIDEA features to navigate python source file. There is no code in the project. I have opened an new project and with an empty file.

 

 

0
Comment actions Permalink

Ah, I see.

Bytearray is implemented in another language (C/C++). In this case, PyCharm generates python_stubs automatically, and use it for code completion and type checking.

string.py, on the other hand, implemented in python, so PyCharm finds the actual module.

Is there any issue with this behavior?

1

Please sign in to leave a comment.