Bug description
def convert_type(x, type): # pylint: disable=missing-function-docstring,redefined-builtin
return type(x)
convert_type(12.34, str).split('.')
For the final line, pylint reports:
E1101: Class 'float' has no 'split' member (no-member)
If type is renamed in the function definition, then pylint reports no errors.
The exact false positive reported is not always the same. I believe the fundamental problem is that pylint does not know how to handle when type has been shadowed, and acts as though it has not been. Hence in the above example, it thinks that the function call returned the float class, since that is what it would be if the built-in type had actually been used.
I would like to mention that I am not an advocate for shadowing builtins like this. I came across this issue when I was working on existing code authored by someone else. But even though shadowing builtins is bad practice, this does seem like something pylint should be able to understand.
Configuration
Command used
pylint --errors-only a.py
Pylint output
************* Module a
/tmp/a.py:4:0: E1101: Class 'float' has no 'split' member (no-member)
Expected behavior
I would expect it to report no errors, like it does when you write the same code but without redefining type.
Pylint version
pylint 4.0.5
astroid 4.0.4
Python 3.13.3 (main, May 9 2025, 23:49:05) [GCC 12.2.0]
OS / Environment
I discovered this in the Debian Python 3:13 docker image. It seems to be Debian 12 (bookworm).
Additional dependencies
Bug description
For the final line,
pylintreports:If
typeis renamed in the function definition, thenpylintreports no errors.The exact false positive reported is not always the same. I believe the fundamental problem is that
pylintdoes not know how to handle whentypehas been shadowed, and acts as though it has not been. Hence in the above example, it thinks that the function call returned thefloatclass, since that is what it would be if the built-intypehad actually been used.I would like to mention that I am not an advocate for shadowing builtins like this. I came across this issue when I was working on existing code authored by someone else. But even though shadowing builtins is bad practice, this does seem like something
pylintshould be able to understand.Configuration
Command used
Pylint output
Expected behavior
I would expect it to report no errors, like it does when you write the same code but without redefining
type.Pylint version
OS / Environment
I discovered this in the Debian Python 3:13 docker image. It seems to be Debian 12 (bookworm).
Additional dependencies