Skip to content
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

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

Closed
cboxed opened this issue Jul 27, 2022 · 3 comments
Closed

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

cboxed opened this issue Jul 27, 2022 · 3 comments

Comments

@cboxed
Copy link

cboxed commented Jul 27, 2022

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:

  • package/bleparser/altbeacon.py
  • package/bleparser/ibeacon.py
  • package/bleparser/tilt.py

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
Copy link
Owner

Ernst79 commented Jul 27, 2022

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
Copy link
Author

cboxed commented Jul 27, 2022

You are right. This works. I created a pull request: #38

@Ernst79
Copy link
Owner

Ernst79 commented Jul 28, 2022

Thanks , I releas a new version.

@Ernst79 Ernst79 closed this as completed Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants