nhairs / python-json-logger

JSON Formatter for Python Logging
https://nhairs.github.io/python-json-logger/
BSD 2-Clause "Simplified" License
28 stars 5 forks source link

Move to importlib.util.find_spec for checking if packages are installed #25

Closed nhairs closed 2 weeks ago

nhairs commented 2 months ago

Per title, move to importlib.util.find_spec over try: import name; catch ImportError.

This allows us to check for installed modules (i.e. orjson, msgspec) without actually importing them.

Ref: https://stackoverflow.com/a/14050282/12281814

nhairs commented 2 weeks ago

Fixed in #27