launchpadlib methods do not support positional parameters

Bug #270096 reported by Brad Crittenden
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
launchpadlib
Triaged
Low
Unassigned

Bug Description

When invoking methods on a launchpadlib Launchpad object positional arguments are not accepted. So if you try the following you get an exception:

>>> lp.people.findTeam("bzr")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __call__() takes exactly 1 argument (2 given)

In order to make the method call you must name all parameters:

>>> lp.people.findTeam(text="bzr")
<launchpadlib.resource.Collection object at 0x8616f8c>

If launchpadlib cannot be made to accept positional arguments it should be documented. Looking at the help file (https://help.launchpad.net/API/launchpadlib) and the reference guide (http://people.ubuntu.com/~flacoste/launchpad-api-doc.html) there is no mention of this unPythonic restriction and I think many programmers will be confused.

Tags: ui
Changed in launchpadlib:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
Leonard Richardson (leonardr) wrote :

We looked into this a while back. It's not really possible to make this work in the general case because the rules for exporting arguments through the web service are different from the rules for writing a Python method. It's possible to make this work in the degenerate case where an operation has only one argument, but it's still enough client-side programming that I didn't pick it up.

In the meantime, I've updated the launchpadlib documentation.

Revision history for this message
Gavin Panella (allenap) wrote :

This looks like a Won't Fix from what Leonard has said, unless we want those degenerate cases?

Changed in launchpadlib:
status: Triaged → Won't Fix
Revision history for this message
Francis J. Lacoste (flacoste) wrote :

No actually, there is a way to do this. We just need to export the parameter orders in the WADL. So it's still on the radar.

Changed in launchpadlib:
status: Won't Fix → Triaged
Revision history for this message
Tim Penhey (thumper) wrote :

I hit this too and it confused me somewhat.

I've got a branch with a fix that just raises a slightly more helpful error message if positional args are used.

Revision history for this message
Leonard Richardson (leonardr) wrote :

That sounds good. Can you get that reviewed and land it?

Changed in launchpadlib:
importance: Medium → Low
tags: added: ui
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.