-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with python 3.7 and "async" as parameter name #558
Comments
Note that Fedora already is switching to Python 3.7. |
It appears that async is part of the API which makes things hard to fix just by renaming. I have a decorator that might be useful for this (consider it Public Domain or CC0): from functools import wraps
def deprecated_async(func):
"""A decorator, that let's us keep our old API, but deprecate it"""
@wraps(func)
def inner(*args, **kwargs):
if 'async' in kwargs:
if 'asynchronous' in kwargs:
raise ValueError('cannot use both async and asynchronous '
'keyword arguments! the latter obsoletes the first.')
warnings.warn('async keyword argumnt is deprecated, '
'use asynchronous instead', DeprecationWarning)
kwargs['asynchronous'] = kwargs.pop('async')
return func(*args, **kwargs)
return inner
@deprecated_async
def awesome_func(foo, bar, asynchronous=False):
"""People can pass async or asynchronous"""
... |
OMG, it looks like a breaking change, btw this part is generated by swagger-codegen. What does it mean "fedora is switching to p37" ? |
|
Thanks @hroncok , so Fedora 29 will use it. I though that latest version was switched or something ;) |
But Fedora 29 already needs to use it at this point. From user perspective, this is something form the future, but from ours, it's the current one. |
Since Homebrew updated Python to 3.7, my workaround for the Ansible OpenShift and Kubernetes integration was to run this little sed command in the kubernetes/openshift python module directory:
Hope it helps someone until the issue is fixed properly |
I ran into this after Homebrew updated Python to 3.7 this morning. @Chekov2k, how are you installing the Kubernetes python package to that directory? If I do a |
@jbiel I just ran pip3 install kubernetes openshift with a clean install of python3 beforehand |
Thanks @Chekov2k. I ended up using this:
|
I opened PR in swagger-codegen and added a simple workaround to gen repository. Next release should support Python 3.7. If you can't wait I suggest running
where OUTPUT_DIR is the path to the library. |
Closing as new releases have been generated using kubernetes-client/gen#67 |
… for 3.7 compatibility
In python 3.7, async is a reserved keyword [1]. This module is using async as parameter name in different methods and it's failing with syntax errors like (excerpt):
File "/usr/local/lib/python3.7/site-packages/kubernetes/client/apis/admissionregistration_api.py", line 120
async=params.get('async'),
^
SyntaxError: invalid syntax
byte-compiling /tmp/test/usr/local/lib/python3.7/site-packages/kubernetes/client/apis/storage_v1alpha1_api.py to storage_v1alpha1_api.cpython-37.pyc
File "/usr/local/lib/python3.7/site-packages/kubernetes/client/apis/storage_v1alpha1_api.py", line 132
async=params.get('async'),
^
SyntaxError: invalid syntax
byte-compiling /tmp/test/usr/local/lib/python3.7/site-packages/kubernetes/client/apis/autoscaling_api.py to autoscaling_api.cpython-37.pyc
File "/usr/local/lib/python3.7/site-packages/kubernetes/client/apis/autoscaling_api.py", line 120
async=params.get('async'),
^
SyntaxError: invalid syntax
Note that python 3.7 was released recently and some distros (as fedora) will be switching to it.
[1] https://docs.python.org/3.7/whatsnew/3.7.html#summary-release-highlights
The text was updated successfully, but these errors were encountered: