pylint
pylint copied to clipboard
Inside a sys.version_info guard, unexpected-keyword-arg returns error for version-specific keyword arg
Bug description
# pylint: disable=missing-module-docstring
# pylint: disable=multiple-imports
import shutil, sys
if sys.version_info >= (3, 13):
shutil.chown('/tmp/doesntexist', 222, 222, follow_symlinks=False)
else:
shutil.chown('/tmp/doesntexist', 222, 222)
Configuration
No response
Command used
pylint /tmp/testme.py
Pylint output
************* Module testme
/tmp/testme.py:7:4: E1123: Unexpected keyword argument 'follow_symlinks' in function call (unexpected-keyword-arg)
------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)
Expected behavior
To not see an error? :D
Either pylint should not try to validate keyword arguments it cannot validate (because it can't know what keyword arguments are going to run inside a sys.version_info check) or it should only check the branch it detects is suitable for the version of python it's implemented under.
Pylint version
pylint 3.1.1
astroid 3.1.0
Python 3.11.9 (main, Apr 27 2024, 23:35:49) [GCC 13.2.1 20240210]
OS / Environment
Gentoo Linux
Additional dependencies
No response
Similar to #7240 / #9610, we need better sys guard comprehension in astroid