Python Syntax Error in async=params.get('async')

206 views
Skip to first unread message

colind...@gmail.com

unread,
Feb 28, 2020, 3:37:11 PM2/28/20
to Kill Bill users mailing-list
Hello,

After installing the Python client as mentioned on the Github I seem to run into an error already when importing the killbill module
import killbill

Which resulted in
...\killbill\api\account_api.py", line 177

    async=params.get('async'),
    ^
SyntaxError: invalid syntax

This line occurs multiple times in the account_api.py file. The first time it occurs is in:
        return self.api_client.call_api(
            '/1.0/kb/accounts/{accountId}/block', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='List[BlockingState]',  # noqa: E501
            auth_settings=auth_settings,
            async=params.get('async'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

I thought it might have to do with the newer Python version (3.8.1)  so I also tried it with 3.7.4 and 3.5.4, however, it did not have any effect. Is it correct Kill Bill should support Python 2.7 or 3.4 and up?

Since I have no clue what I did wrong. Any ideas/suggestions on how to fix this issue?

Thanks in advance,
Colin

stephane brossier

unread,
Feb 28, 2020, 5:01:47 PM2/28/20
to colind...@gmail.com, Kill Bill users mailing-list
Colin,

We have tested the client using Python 2.7.17, so it is possible that things don't work with 3.x versions. I am not python expert, so if you have inputs on what has changed and how to fix it that would be helpful. If not, we'll investigate, but this may take some time.

Stéphane


--
You received this message because you are subscribed to the Google Groups "Kill Bill users mailing-list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to killbilling-us...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/killbilling-users/54890dfe-712c-48e9-afd7-f3009bcb7360%40googlegroups.com.

colind...@gmail.com

unread,
Feb 29, 2020, 6:53:36 AM2/29/20
to Kill Bill users mailing-list
Dear Stéphane, 

Thank you for the quick reply. 

I just tested it on Python 2.7.17 in a conda virtual environment and the error did not appear. The error might have to do something with the change in language encoding. Python 2 used stores strings as ASCII and Python 3 uses Unicode (https://learntocodewith.me/programming/python/python-2-vs-python-3/). 

 we'll investigate, but this may take some time
Yes please if you can. Thank you in advance!  

This issue is blocking our project as we do not want to develop on the deprecated Python 2. Are there any plans in the future to test on Python 3 and releasing a compatible branch?

stephane brossier

unread,
Mar 2, 2020, 8:35:12 PM3/2/20
to colind...@gmail.com, Kill Bill users mailing-list
Colin,

I have filed the issue here, and so we will get to it eventually but this competes with everything else and our python knowledge is quite limited.

If you have some python knowledge in your team and if you care about this being fixed sooner than later, I would encourage you to submit a PR at least do some
research to ease the work on our end.

Best,

Stéphane


--
You received this message because you are subscribed to the Google Groups "Kill Bill users mailing-list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to killbilling-us...@googlegroups.com.

colind...@gmail.com

unread,
Mar 6, 2020, 9:34:14 AM3/6/20
to Kill Bill users mailing-list
Stéphane,

Thank you for filling the issue. Unfortunately, my company does not have enough resources to look into this issue. In an attempt to easy work on your side I came accros
Automated Python 2 to 3 code translation in the documentation (https://docs.python.org/3.8/library/2to3.html). I tried to transform the py files with this method. I placed the py files in a map on the desktop and ran the following command for the entire directionary:

C:\Users\...\DeskTop python C:\Users\...\Python38\Tools\scripts\2to3.py --output-dir=killbill_copy -W -n C:\Users\...\Desktop\killbill_folder

To script ran succesfully, however, I was not able to install a custom module in Anaconda. Perhaps this helps you. 

Kind regards,
Colin

Tasos

unread,
Oct 14, 2020, 12:31:56 PM10/14/20
to Kill Bill users mailing-list
hello mr colind, i have the same problem and im using pycharm, did you come with a solution for this error? 

the thing is that when im running my script with 2.7.17 python version , create_acount function throws an error like this :

(venv) C:\Users\tgian\PycharmProjects\killbilltest>python account.py
Traceback (most recent call last):
  File "account.py", line 11, in <module>
    account = account_api.create_account(body, 'tutorial', 'bob', 'lazar')
TypeError: create_account() takes at most 3 arguments (5 given)

kill_bill_python27.PNG

did you have the same problem using 2.7.17 version?

Thank you in advance

Colin de Ruiter

unread,
Oct 15, 2020, 1:50:56 PM10/15/20
to Kill Bill users mailing-list
Dear Tasos, 

We had the same issue as you with version 2.7.17. Unfortunately, we didn't have the Python resources to fix this issue or look into it. We decided to just use the REST API with another group of developers.

I assume the REST API works as expected because I didn't hear any about any issues from our development. Hopefully, that will be an option for you. 

Kind regards, 
Colin

Op woensdag 14 oktober 2020 om 18:31:56 UTC+2 schreef Tasos:

Varun Vora

unread,
Jan 4, 2021, 9:58:21 AM1/4/21
to Kill Bill users mailing-list
Hi, 

According to me, the cause for this issue is that 'async' is a keyword in python since 3.5 and became a reserved keyword from Python 3.7
Most projects have gone about this fix by replacing the `async` with `asynchronous`. Most open-source Python projects have gone with this approach. However, in our case, the client is expecting `kwargs` in the methods' arguments.  Therefore, merely replacing the word in the project might cause an issue for those who are passing the key `async` through a dictionary. 

There are two ways of fixing this:
1. Replace `async` with `asynchronous` and inform in the release notes that this is something the user need's to consider when upgrading the client version. This is simple but the maintainers may have a good reason to forbid it. 
2. Replace `async` with `asynchronous` and also modify the logic to read the params for `async`. This will ensure backward compatibility but would be a lot more time-consuming for the developer and reviewer. It may also make the code slightly uglier.

Let me know what you all think.

Pierre-Alexandre Meyer

unread,
Jan 4, 2021, 10:35:49 AM1/4/21
to Varun Vora, Kill Bill users mailing-list
Hi Varun,

Thank you for the explanation!

The client is auto-generated using swagger-codegen, and I believe this was fixed upstream here: https://github.com/swagger-api/swagger-codegen/pull/8401

I would suggest to re-generate the Python client using the latest version of swagger-codegen and verify the basic integration tests still work (https://github.com/killbill/killbill-client-python/blob/master/test/test_integration.py). We can highlight the change in the release notes.

--
You received this message because you are subscribed to the Google Groups "Kill Bill users mailing-list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to killbilling-us...@googlegroups.com.

Marius U

unread,
Nov 20, 2023, 8:33:48 PM11/20/23
to Kill Bill users mailing-list
Is this library still maintained? This thread is 3 years old, but Python library has not been fixed yet.

Shall Python Client be considered unsupported?

Thanks!
-Marius

karan bansal

unread,
Nov 21, 2023, 11:11:07 AM11/21/23
to Kill Bill users mailing-list
Hi Marius,

We recently went through all the python codes for the api endpoints and added/corrected the required code. Though we used the library with older versions of python and it worked perfectly. Let me check with the Dev team about upgrading it according to latest python versions.

Regards
Karan

Marius U

unread,
Nov 22, 2023, 9:54:53 PM11/22/23
to Kill Bill users mailing-list
Hi,

That would be great. If it helps, I tried generating the code locally with latest 2.x.x swagger codegen release, and all works fine.

I'm running into other local development issues that don't allow me to fully test this, or I'd send a PR.

If you folks could upgrade the code generator that would be great.

Thanks!
Reply all
Reply to author
Forward
Message has been deleted
0 new messages