Shadows built-in names "function" and "module" with PyCharm

Viewed 24770

I have the following Python code:

function = "Developer"
module = "something"
print(function + " on " + module)

With PyCharm 2017, I have a bubble which says “Shadows built-in names "function"/"module" with PyCharm”.

I’m surprised because "function" and "module" are not built-in names. They are not keywords either:

import __builtin__
import keyword

assert "function" not in dir(__builtin__)  # -> OK
assert "module" not in dir(__builtin__)    # -> OK
assert "function" not in keyword.kwlist    # -> OK
assert "module" not in keyword.kwlist      # -> OK

What’s wrong?

I’m using CPython 2.7, but have the same trouble with 3.5 & 3.6.

EDIT:

__builtin__ is now builtins in Python 3.

2 Answers
Related