For a week the Python world was a bit broken
Tags: python, testing
Published: 2018-12-11 11:29:48

---
title: For a week the Python world was a bit broken
published: true
description: On December the fourth something broke within the Python world. The cause? An update of a dependency.
tags: python, testing
---

If you know a bit of python, you probably know the very popular library [requests](https://github.com/requests/requests) created by Kenneth Reitz. 

You might have noticed that your CI tool (Travis or other) was complaining about something if you use requests directly in your project or rely on another library that uses requests.

By opening the logs of your CI tool, they would show something like this:

```python
Traceback (most recent call last):
  (...)
  raise VersionConflict(dist, req).with_context(dependent_req)
  pkg_resources.ContextualVersionConflict: 
      (idna 2.8 (/home/travis/build/.../.../.tox/py35/lib/python3.5/site-packages),
      Requirement.parse('idna<2.8,>=2.5'), {'requests'})
  (...)
```

Okay,  at first glance there was some issue within `requests` and `idna`. So what happened?

## The IDNA library

**What is this library for?**
According to the library readme, this library offers _"[s]upport for the Internationalised Domain Names in Applications (IDNA) protocol as specified in [RFC 5891](https://tools.ietf.org/html/rfc5891)_ and _also provides support for Unicode Technical Standard 46._

**What happened?**
On the 4th of December, the [IDNA library](https://github.com/kjd/idna) gets an update and a bump of version to 2.8. Since requests were specifying that this library needs to have a version between 2.5 to 2.7 as soon as the library got updated Travis got upset.

## An update to requests
 
 A week later, on December the 10th,  requests get updated and its version bumped to 2.21.0. With this update, requests accept the new version of the IDNA library. 
 
 Travis and other CI tools are now happy once more and you can get your PR merged again.
 

## The fix

Fixing this issue is quite easy. Simply specify the version of idna that requests needs within your project. This will make Travis pull that version of idna and the requirements of requests won't conflict anymore.

On your `requirements.txt` or any other file you use to manage your dependencies adding the following will fix the failing tests.

```python
idna == 2.7
```

You can apply this with any conflicting libraries that you might have until things get fixed and you are able to use the most up to date versions.


 
## Conclusion

Does this all mean that the world of Python was indeed broken? Not at all, but if you use requests on your project, then for a week your  CI tool wasn't happy(unless you pin the idna version).

In [opsdroid](https://github.com/opsdroid/opsdroid) we had to wait until requests got updated so we could merge two PRs which itself is not a big deal.

This episode made me realise how important dependencies are within projects and how something can break without being directly your fault or anyone's fault really.

I would love to hear how do you keep track with your dependencies and updates to these dependencies. Do you just merge new updates or do some testing beforehand?

_I'd like to thank to [@rhymes](https://dev.to/rhymes) for showing me how home assistant solved this issue._