Renaming variables not reliable when editing a Jupyter notebook in Pycharm?

Viewed 1077

As can be seen in the screenshot I am renaming the variable bdir to originalsDir - and notice there are two additional usages after its definition:

enter image description here

But after confirming to Refactor only the variable itself is changed - and not its usages .. which now become red since they are orphaned:

enter image description here

Why would this be happening? I must believe this were some kind of corner case since a fundamental feature of variable renaming would not easily slip through Jetbrains QA ..

1 Answers

Rename refactor for variables in the global scope requires indexing which requires a physical file and that's a problem with notebooks as the source code representation in PyCharm is a virtual file on top of real JSON content (https://stackoverflow.com/a/56473212/2787185).

This feature will certainly be implemented as the new Jupyter support development is a priority and in active state. The relevant ticket in the bug tracker https://youtrack.jetbrains.com/issue/PY-34670

Related