explosion / curated-transformers

🤖 A PyTorch library of curated Transformer models and their composable components
MIT License
864 stars 34 forks source link

Backport: Fix activation lookup with Python 3.12.3 (#375) #377

Closed danieldk closed 6 months ago

danieldk commented 6 months ago

Description

We used the metaclass EnumMeta/EnumType to override reporting of missing enum values (to give the full set of supported activations). However, in Python 3.12.3, the default value of the name parameter of EnumType.__call__ method was changed from None to _not_given:

https://github.com/python/cpython/commit/d771729679d39904768f60b3352e02f5f491966c

Even though this is a public API (which now uses a private default value), it seems too risky to continue using it. So in this change, we implement Enum.__mising__ instead for the improved error reporting.

Checklist