Pylint 3.3.0 does not recognize f-string as string and reports no-member for startswith() #9947
Closed
Description
Bug description
The following file test_pylint.py:
#!/usr/bin/env python
"""module"""
class Cls:
# pylint: disable=too-few-public-methods
"""Cls"""
c_obj = Cls()
c_repr1 = '{!r}'.format(c_obj) # pylint: disable=consider-using-f-string
c_repr2 = f'{c_obj!r}'
assert c_repr1.startswith('<__main__.Cls')
assert c_repr2.startswith('<__main__.Cls') # pylint reports no-member
causes pylint to report this issue:
$ pylint test_pylint.py
************* Module tmp_issues.test_pylint
test_pylint.py:16:7: E1101: Instance of 'Cls' has no 'startswith' member (no-member)
I tested this with multiple pylint versions, and the first version that has this behavior is pylint 3.3.0.
Command used
pylint test_pylint.py
Pylint output
************* Module test_pylint
test_pylint.py:16:7: E1101: Instance of 'Cls' has no 'startswith' member (no-member)
Expected behavior
Pylint should not report this as an error, because an f-string is a string and has the startswith() method.
Pylint version
pylint 3.3.0
astroid 3.3.3
Python 3.12.4 (main, Jun 6 2024, 18:26:44) [Clang 15.0.0 (clang-1500.3.9.4)]
OS / Environment
macOS Sonoma 14.6.1