https://github.com/google/magika
Magika is a novel AI powered file type detection tool that relies on the recent advance of deep learning to provide accurate detection.
It's not a sliver bullet, but I use it recently for inspecting file type instead of magic file.One advantage is that detecting composed files. Take pdf+exe file for example, the library will report something like 70% pdf and 30% pebin file.