paulc / dnslib

A Python library to encode/decode DNS wire-format packets
https://github.com/paulc/dnslib
BSD 2-Clause "Simplified" License
295 stars 84 forks source link

Bimap to Enum #55

Closed jack60612 closed 6 months ago

jack60612 commented 11 months ago

Hello, I was wondering if you would be open to using Enum instead of Bimap? I will happily make a PR if you are open to the change.

paulc commented 6 months ago

That would probably be sensible (Bimap was a hack before Enums were supported) but I would want to bundle with a broader release which dropped support for Python 2 & Python <3.7 (see comments on Issue #56)

nhairs commented 6 months ago

nit: I feel like this issue should also be left open - @paulc

Looking at the code I'm not sure how easy it will be to replace Bimap with enum.IntEnum. Specifically, I'm not sure if the Bimap fallback behaviour is replicated with an enum.

That said if we can make it work it would be good to use more "standard" components.

nhairs commented 5 months ago

@jack60612 - you might be interested in checking out my typing branch (PR #61). It might serve as a good base if you do want to try switching to Enum.

jack60612 commented 5 months ago

@jack60612 - you might be interested in checking out my typing branch (PR #61). It might serve as a good base if you do want to try switching to Enum.

i think i ended up just working with it but thanks for the offer!