.. _redefined-builtin: redefined-builtin / W0622 ========================= **Message emitted:** ``Redefining built-in %r`` **Description:** *Used when a variable or function override a built-in.* **Problematic code:** .. literalinclude:: /data/messages/r/redefined-builtin/bad.py :language: python **Correct code:** .. literalinclude:: /data/messages/r/redefined-builtin/good.py :language: python **Additional details:** The :ref:`allowed-redefined-builtins ` option lets you specify names that are permitted to shadow built-ins. However, this option is not effective for redefinitions at the module level or for global variables. For example: Module-Level Redefinitions:: # module_level_redefine.py id = 1 # Shadows the built-in `id` Global Variable Redefinitions:: # global_variable_redefine.py def my_func(): global len len = 1 # Shadows the built-in `len` Rationale: Shadowing built-ins at the global scope is discouraged because it obscures their behavior throughout the entire module, increasing the risk of subtle bugs when the built-in is needed elsewhere. In contrast, local redefinitions are acceptable as their impact is confined to a specific scope, reducing unintended side effects and simplifying debugging. Created by the `variables `__ checker.