Salt: Async is a protected word in python 3.7

Created on 12 Jul 2018  路  9Comments  路  Source: saltstack/salt

Description of Issue/Question

We use the word async throughout salt, and it has become a reserved word in python 3.7.

This will cause breaking changes in salt if we change this in an old release, because we use the keyword async in client mixins.

This will need to be fixed for us to support python3.7

Core P1 ZRELEASED - 2018.3.3 ZRELEASED - Fluorine severity-critical severity-high team-core

Most helpful comment

Mainly this is salt.utils.async that we probably also need to rename. This doesn't seem to be hard to fix:

  • Rename salt.utils.async to salt.utils.asynchronous (because other shortcuts are just confusing).
  • Rename variables from async to asynchronous too.

But we will likely need to port this to 2018.3 too.

All 9 comments

Python 3.7.0 (default, Jul  2 2018, 17:10:55)
[Clang 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> async = True                                                                                                                                                                                                                                                                                                      4.8m
  File "<string>", line 1
    async = True
          ^
SyntaxError: invalid syntax
>>> import salt.utils.async
  File "<stdin>", line 1
    import salt.utils.async
                          ^
SyntaxError: invalid syntax
$  python salt/utils/async.py
  File "salt/utils/asyncmod.py", line 50
    self.async = method(*args, **kwargs)
             ^
SyntaxError: invalid syntax

Keyword added to the reserved words in 3.7

https://docs.python.org/3/reference/lexical_analysis.html#keywords

await was also added, but we do not use that afaik.

@saltstack/team-core @saltstack/team-suse do yall have any thoughts on this?

Right now we are talking about only making this change in develop.

Mainly this is salt.utils.async that we probably also need to rename. This doesn't seem to be hard to fix:

  • Rename salt.utils.async to salt.utils.asynchronous (because other shortcuts are just confusing).
  • Rename variables from async to asynchronous too.

But we will likely need to port this to 2018.3 too.

Also there are some places, like salt.client.get_local_client where I named kwarg sync to avoid using the async keyword. I propose to refactor this name too.

We are going to fix this in 2018.3.3 and Fluorine, but not 2017.7

This has been completed and is in both 2018.3 and Fluorine for the next releases.

@meaksh @dincamihai @brejoc could you please get the port to the package?

There is one that we missed, that is left in the test suite.

Was this page helpful?
0 / 5 - 0 ratings