brevity

From IndieWeb

Brevity is a tiny Python library for shortening note text to an acceptable length for posting Twitter, accounting for t.co URL shortening.

The package can be installed with pip install brevity and source is on GitHub