Envisalink not compatible with Python 3.7

Hey @Cinntax,
You don’t have issues enabled on your pyenvisalink github page so hopefully I can get a hold of you here.

It appears that pyenvisalink isn’t compatible with python 3.7 since it errors out with:

>>> import pyenvisalink
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/pyenvisalink/__init__.py", line 2, in <module>
    from .envisalink_base_client import EnvisalinkClient
  File "/usr/local/lib/python3.7/site-packages/pyenvisalink/envisalink_base_client.py", line 14
    from asyncio import async
                            ^
SyntaxError: invalid syntax

I’ve reverted to python 3.6.5 for the time being.

Hey- I promise I’m still here :). i took a look at this, and I’m wondering if maybe there was a missing dependency on your 3.7 environment.

I say that because if you see the code here, the only way we should get to line 14 there is if the “ensure_future” failed to import. I just tested on python 3.7 and it appears to still be valid (although in 3.7 they did introduce a helper method that could replace this one).

You should be able to run that first import there without issue on python 3.7.

try:
    from asyncio import ensure_future
except ImportError:
    # Python 3.4.3 and earlier has this as async
    # pylint: disable=unused-import
    from asyncio import async
    ensure_future = async

Good question. I’ll take another look. It was failing in home assistant so I tried importing it right in Python 3.7.

You should enable issues on your repo though :wink:

:slight_smile: nevermind- i was able to reproduce. The issue is that i guess in python 3.7 it’s actually a syntax error to attempt to import that deprecated function- so even though the actual execution is never getting there, it’s still failing from the get-go.

That piece of code was to enable backward compatibility with python 3.4 and prior. Since HASS doesn’t support python 3.4 anymore, I just got rid of it, and updated my requirements to say i’m only supporting 3.5+. I have included a new pull request into HASS for this! Thanks for the heads up- at some point pretty much everyone would have been broken!!

Oh- issues are now on!