Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Test for memory leaks as described in #198 * Possible fix for #198: memory leak * Optimization: avoid holding frame reference when locals == globals * Get caller frame at decoration-time Here we are more careful about which caller's locals we use to resolve forward type references. We want the callers locals at decoration-time — not at decorator-construction time. Consider: ```py frozen_dataclass = marshmallow_dataclass.dataclass(frozen=True) def f(): @custom_dataclass class A: b: "B" @custom_dataclass class B: x: int ``` The locals we want in this case are the one from where the custom_dataclass decorator is called, not from where marshmallow_dataclass.dataclass is called. * Add ability to pass explicit localns (and globalns) to class_schema When class_schema is called, it doesn't need the caller's whole stack frame. What it really wants is a `localns` to pass to `typing.get_type_hints` to be used to resolve type references. Here we add the ability to pass an explicit `localns` parameter to `class_schema`. We also add the ability to pass an explicit `globalns`, because ... might as well — it might come in useful. (Since we need these only to pass to `get_type_hints`, we might as well match `get_type_hints` API as closely as possible.) * test: check for frame leakage when decorators throw exceptions * Fix mypy by setting python to the minimum supported version, 3.8 --------- Co-authored-by: Jeff Dairiki <dairiki@dairiki.org>
- Loading branch information