opendp / opendp

The core library of differential privacy algorithms powering the OpenDP Project.
https://opendp.org
MIT License
284 stars 46 forks source link

optional dependency context #1520

Closed mccalluc closed 3 weeks ago

mccalluc commented 3 weeks ago

This might be a little cleaner:

- pl = import_optional_dependency("polars", raise_error=False)
- if pl is not None:
+ with optional_dependency("polars") as pl:
mccalluc commented 3 weeks ago

Context managers can't skip code: That's just not what they do. We could have a context manager, but then we'd also need to handle possible exceptions outside, and that's worse. Closing.