I got stung by this one (using len
in an argument on a method call), then defining a list, and doing len on it, yielding:
def fun(len):
a = []
...
len(a)
>>>TypeError: 'int' object is not callable
Is there Python3 lint for the VS Code IDE, that you can configure to report on variables not being reserved words/built-in functions? Or masking/overwriting in general. I didn't expect that behaviour.
On reflection I am aware it's a feature of Python that you can pass functions as arguments, hence the dual syntax of len
and len()
. But it certainly caught me by surprise!
Lint seems to report things like unused variables.
It seems inconsistent it doesn't provide name mask reporting out of the box too.
If this is feasible, can someone please advise how to set it up in VS Code?
Environment:
- VS Code: Version 1.23.1
- Python 3.6.5
- Python Extension 2018.4.0
- Microsoft Windows Server 2012 RC2.