Skip to content

lambda from __getattr__ getting called with "connection" as a keyword argument? #32

@151henry151

Description

@151henry151

This code:

#!/usr/bin/env python2
import bigcommerce
import bigcommerce.api
BIG_URL = 'store-45eg5.mybigcommerce.com'
BIG_USER = 'henry'
BIG_KEY = '10f0f4f371f7953c4d7d7809b62463281f15c829'

api = bigcommerce.api.BigcommerceApi(host=BIG_URL, basic_auth=(BIG_USER, BIG_KEY))
def get_category_id(name):
    get_request = api.Categories.get(name)
    try:
        cat_list = api.Categories.all(name=name)
        if cat_list:
            return cat_list[0]['id']
        else:
            return None
    except:
        return None
def create_category(name):
    rp = api.Categories.create(name)
    if rp.status == 201:
        return rp.json()['id']
    else:
        return get_category_id(name)
create_category('anothertestingcat')

Gives this traceback:

Traceback (most recent call last):
File "./bigcommerceimporter.py", line 50, in
create_category('anothertestingcat')
File "./bigcommerceimporter.py", line 44, in create_category
rp = api.Categories.create(name)
File "/home/henry/big_test_zone/local/lib/python2.7/site-packages/bigcommerce/api.py", line 57, in
return lambda _args, *_kwargs: (getattr(self.resource_class, item))(_args, connection=self.connection, *_kwargs)
TypeError: create() got multiple values for keyword argument 'connection'

I believe this is a bug/glitch in or around line 57 in api.py. It looks like lambda from getattr is getting called with "connection" as a keyword argument when it shouldn't be.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions