Module psdi_data_conversion.compatibility
psdi_data_conversion/compatibility.py
Created 2026-09-22 by Bryan Gillis.
Different versions of methods etc. to help with compatibility with different versions of Python. Official tools are used where possible, with fallback to implementations here if not
Classes
class DummySubtests (**kwargs)-
Expand source code
class DummySubtests: """Fallback for Pytest's `subtests` fixtrue, which just sets up a dummy context manager which will result in any subtest failing immediately failing the enclosing test""" def __init__(*args, **kwargs): return def test(self, *args, **kwargs) -> AbstractContextManager: return _dummy_context_manager()Fallback for Pytest's
subtestsfixtrue, which just sets up a dummy context manager which will result in any subtest failing immediately failing the enclosing testMethods
def test(self, *args, **kwargs) ‑> contextlib.AbstractContextManager-
Expand source code
def test(self, *args, **kwargs) -> AbstractContextManager: return _dummy_context_manager()
class batched (iterable, n)-
Batch data into tuples of length n. The last batch may be shorter than n.
Loops over the input iterable and accumulates data into tuples up to size n. The input is consumed lazily, just enough to fill a batch. The result is yielded as soon as a batch is full or when the input iterable is exhausted.
>>> for batch in batched('ABCDEFG', 3): ... print(batch) ... ('A', 'B', 'C') ('D', 'E', 'F') ('G',)