Ernst79 / bleparser

Parser for passive BLE advertisements
MIT License
29 stars 15 forks source link

not compatible with python 3.8 due to dictionary union operator #37

Closed cboxed closed 2 years ago

cboxed commented 2 years ago

In some place the union operator (|) is used to merge dictionaries. Unfortunately this is only supported by python versions >= 3.9 (https://peps.python.org/pep-0584/). According to the setup.cfg python >= 3.8 is supported.

To preserve compatibility with 3.8 the usage of the union operator for dictionaries should be avoided in the following files:

example for ibeacon.py:

This:

sensor_data = {
    CONF_TYPE: DEVICE_TYPE,
    CONF_PACKET: "no packet id",
    CONF_FIRMWARE: DEVICE_TYPE,
    CONF_MANUFACTURER: MANUFACTURER_DICT[comp_id] \
        if comp_id in MANUFACTURER_DICT \
        else DEFAULT_MANUFACTURER,
    CONF_DATA: True
} | tracker_data

Should be changed to:

sensor_data = dict(
    {
        CONF_TYPE: DEVICE_TYPE,
        CONF_PACKET: "no packet id",
        CONF_FIRMWARE: DEVICE_TYPE,
        CONF_MANUFACTURER: MANUFACTURER_DICT[comp_id] \
            if comp_id in MANUFACTURER_DICT \
            else DEFAULT_MANUFACTURER,
        CONF_DATA: True
    },
    **tracker_data
)

I also created a branch with the fixes. But I'm not allowed to push anything ;)

Ernst79 commented 2 years ago

Thanks, i will have a look later this week. Does creating a branch on your own account not work, and create the PR from there?

cboxed commented 2 years ago

You are right. This works. I created a pull request: https://github.com/Ernst79/bleparser/pull/38

Ernst79 commented 2 years ago

Thanks , I releas a new version.