Back to Intellij Community

PyGlobalVariableRedeclarationInNotebookInspection

python/python-psi-impl/resources/inspectionDescriptions/PyGlobalVariableRedeclarationInNotebookInspection.html

2025.3-rc-2711 B
Original Source

Global variable redeclaration in notebook

This inspection detects cases where a global variable is re-declared within the same Jupyter notebook. Redefining global variables can lead to unexpected results or bugs, especially when executing cells in an arbitrary order.

Redefinitions of common loop variables (e.g., i, j, k, etc.) are ignored to reduce noise. However, redefinition of larger objects like lists, DataFrames, or dictionaries is flagged as a potential issue.

If the redefinition is intentional, you can use the provided "Suppress for this statement" quick-fix to silence the warning for that specific occurrence.

Note: This inspection applies only to Jupyter notebook files (.ipynb).