AlenkaF commented on PR #45818: URL: https://github.com/apache/arrow/pull/45818#issuecomment-2838316512
@thisisnic sorry to complicate things a bit — especially since I proposed those test helpers in the first place — but after looking at them again, I’m leaning toward doing the necessary work to support `isinstance(obj, Mapping)` and `isinstance(obj, Sequence)` checks using `collections.abc`. That would involve registering `pa.MapScalar` and `pa.ListScalar` as virtual subclasses with `Mapping.register(...)` and `Sequence.register(...)`, respectively, and possibly implementing a few missing magic methods. Here’s the relevant Python docs I was reading: https://docs.python.org/3/library/collections.abc.html A couple of notes from that page: > Existing classes and built-in classes can be registered as “virtual subclasses” of the ABCs. Those classes should define the full API including all of the abstract methods and all of the mixin methods. This lets users rely on [issubclass()](https://docs.python.org/3/library/functions.html#issubclass) or [isinstance()](https://docs.python.org/3/library/functions.html#isinstance) tests to determine whether the full interface is supported. > knowing that a class supplies __getitem__, __len__, and __iter__ is insufficient for distinguishing a [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence) from a [Mapping](https://docs.python.org/3/library/collections.abc.html#collections.abc.Mapping). Let me know what you think! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org