You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor Translator to use less global state (#165)
In the past, there was one `Translator`, which was a global
singleton, and would be permanently modified any time a new
object class with an `_item_type` was created.
Recently, in v2.0.0a1, we tried out a change where the global
translator would be modified any time a new object class with an
`_item_type` OR with a baseclass with an `_item_type` was created.
This means that every subclass operation mutated global state.
We thought this would make it easier for developers to add their
own classes to the SDK. In retrospect, it makes it much harder
to write tests (because any temporary subclasses created,
including by a mock library, will modify global state for the
rest of the test run), and makes it impossible to intentionally
create a subclass that shouldn't be registered in the
translator. So we are reverting this behavior for v2.0.0a2.
Furthermore, this adds the ability to create non-global
translators (which are, by default, used on `BoxSession`
objects), and the ability to add non-global registrations to
these non-global translators. This is now the publicly
recommended way for developers to register types, outside of the
SDK itself.
For now, the old mechanism of implicitly registering the
official SDK classes with `_item_type` is retained. But we can
experiment with the new system, and see if we prefer to switch
to the explicit registration, and delete the implicit
registration system, in v2.0.0a3.
Also fix a bug that I discovered in `ExtendableEnumMeta`.
0 commit comments