[code-quality] Issues with E1102: "not callable"

Tomàs Núñez tomas at tomas.cat
Tue Aug 1 08:06:48 EDT 2017


Hi
I'm fairly new to pylint and I've followed all the suggestions to clean up
my code and make it more readable. But there's one error I can't get rid of
in this piece of code:

def api_put(api_path, payload):
    """This function makes PUT requests to the api"""
    if api_path.startswith("http"):
        url = api_path
    else:
        url = SERVICE_URL + api_path


The error I'm getting is:

[pylint] E1102:api_path.startswith is not callable


I checked but there's not much info about it:

http://pylint-messages.wikidot.com/messages:e1102


The code works because the argument api_path is a string, so it indeed is
callable. Of course if I change it to:


if str(api_path).startswith("http"):


Then the error disappear. But I already know it is a string, and I've
always read you shouldn't type-check in Python.


Can anyone shed some light? Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/code-quality/attachments/20170801/b1d233f0/attachment.html>


More information about the code-quality mailing list