- Tom Hacohen
This is a bit of a quick update, but we thought it warranted a blog post, because it's something quite a few people have been asking for (our own team included!).
What is Typed Python?
Python is an untyped language, but starting with PEP 484 it now supports type hints. The type hints let you annotate functions with the type information and have it tested in CI to make sure types are correct.
This is an important step for secure coding, and a great improvement for teams that use types in their Python codebase.
As noted in the Python docs,
asyncio is a library to write concurrent code using the
asyncio is used as a foundation for multiple Python asynchronous frameworks that provide high-performance network and web-servers, database connection libraries, distributed task queues, etc.
asyncio is often a perfect fit for IO-bound and high-level structured network code.
Before this change, the Svix library was blocking, which meant that it was blocking the call thread until it got a response from the server. It wasn't a big deal if your code was sync, but for async code it made development slightly more painful, and much less efficient.
How do I use it?
Make sure to update to the latest Python library version (
>=0.53.0 at the time of this writing), and start using it.
Types will automatically work, though you may need to remove any type ignores you added because we didn't have types until now.
asyncio, you will just need to change your code to use the
asyncio variant as so:
from svix.api import Svix svix = Svix("AUTH_TOKEN") app = svix.application.create(ApplicationIn(name="Application name"))
from svix.api import SvixAsync svix = SvixAsync("AUTH_TOKEN") app = await svix.application.create(ApplicationIn(name="Application name"))
Since we were already making so many changes, we took the opportunity to make a small breaking change. This breaking change is very much visible, and if you use it you'll know immediately: we changed the name of the
We had to do it because we also changed the internals a bit to consolidate the type, and we realized that if we kept the same name it may break code in subtle ways. So changing it was the only way to make sure that it will let people know that it has changed.
We are sorry for this, but going forward there will be no breaking changes for this library.
We have a lot more in the works that we'll share in upcoming updates, stay tuned! If you have any thoughts or suggestions regarding what we should work on next, please join the Svix Slack and let us know!