This Week in Changelogs: flask, pytest, IPython, etc
Tags: twic, flask, python, todayilearned
Published: 2023-03-07 21:48:13

### pyenv 2.3.13, 2.3.14

Highlights from the [changelog](https://github.com/pyenv/pyenv/blob/master/CHANGELOG.md#release-2314):
- added versions 3.10.10, 3.11.2, and 3.12.0a5;
- fixed versions 3.5.10 and 3.6.15 for macOS and modern 64-bit platforms.

This one made me laugh a bit:
- [<kbd>a7b181c</kbd>](https://github.com/pyenv/pyenv/pull/2612/commits/a7b181c3caf98aa1aed224b02b5c3c3da108241f#diff-a7f5a90016571f823f0fee81a3d70422bf945159513eaf62c3613b9addffac8aL160-R165) introduce an indentation issue
- [<kbd>3829742</kbd>](https://github.com/pyenv/pyenv/pull/2620/commits/382974214d5f36158f2bd381dbacae5449708a04) fix the indendation issue.

That's how programming actually works!

TIL: `head -n123` is a part of POSIX, `head -123` is a shorthand that can be missing in some operating systems ([pull request](https://github.com/pyenv/pyenv/pull/2629)).

### IPython 8.11.0

Highlights from the [changelog](https://ipython.readthedocs.io/en/stable/whatsnew/version8.html#ipython-8-11):
- `%autoreload` supports meaningful parameters (`%autoreload all`, `%autoreload off`, etc), not only numbers (`%autoreload 0`, `%autoreload 2`, etc).

I like the log of the [pull request](https://github.com/ipython/ipython/pull/13774), it illustrates the approach of implementing a feature step-by-step, one frame at a time:
- [<kbd>a7c76db</kbd>](https://github.com/ipython/ipython/pull/13774/commits/a7c76db7d6dbb961af374b2f34c996eaef5ad62b#diff-776d8acae1dbb42ec4f06629266b825f6eae2cff3da3e6c0ca270b8c9335c8d8R555-R567) get a dumb and working solution
- [<kbd>d8bb14b</kbd>](https://github.com/ipython/ipython/pull/13774/commits/d8bb14b60cce68058769dec4bb2a9e99b33d7150#diff-776d8acae1dbb42ec4f06629266b825f6eae2cff3da3e6c0ca270b8c9335c8d8L575-L588) optimize it
- [<kbd>809ebdf</kbd>](https://github.com/ipython/ipython/pull/13774/commits/809ebdf7fe6b1a27de4f9a4417441b6814468666#diff-776d8acae1dbb42ec4f06629266b825f6eae2cff3da3e6c0ca270b8c9335c8d8R616-R633) and make it nice 

Also, [this fragment](https://github.com/ipython/ipython/pull/13774/files#diff-776d8acae1dbb42ec4f06629266b825f6eae2cff3da3e6c0ca270b8c9335c8d8R611-R629) is quite interesting, `print` and `logger.info` need to be used carefully for logging and protected from being overwritten during hot-reload:

```python
p = print
logger = logging.getLogger("autoreload")
l = logger.info

def pl(msg):
    p(msg)
    l(msg)
```

Everything you wanted to know about GitHub actions:

![GitHub discussion](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eqlxovnqxs10ctjpp60w.png)

### flask 2.2.3

Although the [changelog](https://flask.palletsprojects.com/en/2.2.x/changes/#version-2-2-3) is not that big, I like the thing about `flask run --debug`.

[Previously](https://github.com/pallets/flask/issues/4777#issuecomment-1221500330), it was `flask --debug run` , and it was awkward. The fix itself is [quite small](https://github.com/pallets/flask/pull/4779/files#diff-fed8939d1905b99bba605ad91e9ccdf5ede6223e03ccbc3f0121853035051e62R936), but there's a lot of changes in docs, and also a [PyCharm screenshot](https://github.com/pallets/flask/pull/4779/files#diff-366ddb05690615ba39d8138d6a937585c5854776c1354b6a5e00f8b729ffb41d) was changed. Nice and pure!

### pytest 7.2.1, 7.2.2

The [changelogs](https://docs.pytest.org/en/stable/changelog.html#pytest-7-2-2-2023-03-03) contains mostly bug fixes. [One of them](https://github.com/pytest-dev/pytest/issues/10533) is about `pytest.approx()` causing `ZeroDivisionError` on dicts. 

Another one fixes type checkers behaviour for the [following code](https://github.com/pytest-dev/pytest/pull/10660/files#diff-529eab7698270aede4147aa79fbb77b42c135c4767aa68ec35173504a7389cd9R33), which I think should be illegal:

```python
with pytest.raises(RuntimeError) if val else contextlib.nullcontext() as excinfo:
```

(Please, don't write the code like this.)

And they [fixed](https://github.com/pytest-dev/pytest/pull/10607/files#diff-40c29b1f1136f0a212e98384b44450adaf2c8808fdf14084d4ce78d63dc9d866R649) a race condition when creating directories in parallel, using `os.makedirs(..., exists_ok=True)`. Simple, but helpful.


### whitenoise 6.4.0

The [changelog](https://github.com/evansd/whitenoise/blob/main/docs/changelog.rst#640-2023-02-25) mentions support for Django 4.2. It was good to know, by the way, that `STATICFILES_STORAGE` is [going to be changed](https://docs.djangoproject.com/en/dev/releases/4.2/#custom-file-storages) to `STORAGES` dict ([pull request](https://github.com/evansd/whitenoise/pull/464/files)).

### django-cors-headers 3.14.0

[Changelog](https://github.com/adamchainz/django-cors-headers/blob/main/CHANGELOG.rst#3140-2023-02-25):
- added support for Django 4.2,
- switched from `urlparse` to `urlsplit`.

The [latter](https://github.com/adamchainz/django-cors-headers/pull/793) is the most interesting, `urlsplit` is slightly faster. Also, it's cached, so sometimes you gain a huge performance.

The difference between these functions is that `urlparse` [includes parsing](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlparse) of the "parameters" section of a URL:

```
scheme://netloc/path;parameters?query#fragment
                     ^ this
```

Since it's not widely used, in most cases it's safe to switch from `urlparse` to `urlsplit`.