4 ms·
> How do we know that the log_to_network or route functions are not safe to call at module level? We assume that anything imported from a non-strict module is u
by ben509 7y ago
> How do we know that the log_to_network or route functions are not safe to call at module level? We assume that anything imported from a non-strict module is unsafe, except for certain standard library functions that are known safe.
It's hard to know anything about the stdlib as it can be monkey patched, e.g. [1]
That said, you could solve this with diagnostics; calculate signatures of stdlib functions and classes to find any known safe ones that were patched. Run that check in your test suite to find problematic imports.
> If the utils module is strict, then we’d rely on the analysis of that module to tell us in turn whether log_to_network is safe.
I like this. It seems far more usable than proposals like adding const decorators.[2]
[1]: https://github.com/gevent/gevent/blob/master/src/gevent/monkey.py https://github.com/gevent/gevent/blob/master/src/gevent/monk...
[2]: https://github.com/python/typing/issues/242 https://github.com/python/typing/issues/242