mvdwetering / ynca

Python library to communicate with Yamaha AV Receivers that support the YNCA protocol
MIT License
12 stars 5 forks source link

Python 3.11 compatibility fix #9

Closed mvdwetering closed 1 year ago

mvdwetering commented 1 year ago

Python 3.11 changed the behaviour of format on Enums, see below. This PR makes the Subunit enum use the same format as on 3.10 and with that restores the enum-to-string "conversion" used on the library API (as it was intended by me). Might need to handle this better at some point, but this fixes the immediate issue.

I am not entirely sure why the tests do not detect it at all. The SubunitBase test should have used an actual enum for the DummySubunit used in the test, but changing that to an enum does not catch it. Needs improvment. For now just manual test.

See https://docs.python.org/3/whatsnew/3.11.html#enum

Changed Enum.format() (the default for format(), str.format() and f-strings) to always produce the same result as Enum.str(): for enums inheriting from ReprEnum it will be the member’s value; for all other enums it will be the enum and member name (e.g. Color.RED).