Preparing Django code for the Black stable release

178 views
Skip to first unread message

Paolo Melchiorre

unread,
Oct 20, 2021, 4:59:48 AM10/20/21
to Django developers (Contributions to Django itself)
Hi all,

More than two years ago the 'DEP 0008: Formatting using Black' was accepted with the constraint to wait until Black got to a stable release:
https://github.com/django/deps/blob/main/accepted/0008-black.rst


As you can see from this pull request in the Black code the first stable release is expected for January 2022:
https://github.com/psf/black/pull/2529


I think we can start prepare this great migrations of the Django code so we will be ready when Black 22.0 will be released and we can finally benefit from this change.

We have now more than 2 months to work on this.

Ciao,
Paolo

Mariusz Felisiak

unread,
Oct 20, 2021, 5:37:35 AM10/20/21
to Django developers (Contributions to Django itself)
As you can see from this pull request in the Black code the first stable release is expected for January 2022:
https://github.com/psf/black/pull/2529


I think we can start prepare this great migrations of the Django code so we will be ready when Black 22.0 will be released and we can finally benefit from this change.

We have now more than 2 months to work on this.

Hi

    Do you have any specific steps in mind? I'm not sure how we need to prepare. Implementation, as described in DEP 0008, should be rather straightforward and I don't think anything needs to be done in advance. We (Fellows and OPS team) should be able to implement it within a few days.

Best,
Mariusz

Adam Johnson

unread,
Oct 20, 2021, 6:11:58 AM10/20/21
to django-d...@googlegroups.com
The extension I added to the DEP may be a bit involved:

All code Django generates will also be Black-formatted (startproject, migrations, inspectdb, etc.), at least if the user has Black installed.

But then again it may only need a few calls to black.format_str() in the right places.

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/81687d6f-2ea3-44b4-a9c8-fab71e4e0843n%40googlegroups.com.

Paolo Melchiorre

unread,
Oct 20, 2021, 3:09:16 PM10/20/21
to django-d...@googlegroups.com
On Wed, Oct 20, 2021, 11:37 Mariusz Felisiak <felisiak...@gmail.com> wrote:
I think we can start prepare this great migrations of the Django code so we will be ready when Black 22.0 will be released and we can finally benefit from this change.

Do you have any specific steps in mind? I'm not sot sure how we need to prepare. Implementation, as described in 
DEP 0008, should be rather straightforward and I don't think anything needs to be done in advance. We (Fellows and OPS team) should be able to implement it within a few days.

Hi,

I was thinking we can start right now using black in a branch and see which issue will show up and start fixing them.

Ciao,
Paolo

Markus Holtermann

unread,
Oct 20, 2021, 3:41:39 PM10/20/21
to Django developers
There is https://github.com/MarkusH/django-migrations-formatter which I think holds everything that's necessary to make the migration writer create black-formatted output.

Cheers, Markus

On Wed, Oct 20, 2021, at 11:11 AM, 'Adam Johnson' via Django developers (Contributions to Django itself) wrote:
> The extension I added to the DEP may be a bit involved:
>
>> All code Django generates will also be Black-formatted (startproject,
>> migrations, inspectdb, etc.), at least if the user has Black installed.
>>
> But then again it may only need a few calls to black.format_str() in the
> right places.
>
> On Wed, 20 Oct 2021 at 10:37, Mariusz Felisiak <felisiak...@gmail.com>
> wrote:
>
>>
>> As you can see from this pull request in the Black code the first stable
>>> release is expected for January 2022:
>>> https://github.com/psf/black/pull/2529
>>>
>>> I think we can start prepare this great migrations of the Django code so
>>> we will be ready when Black 22.0 will be released and we can finally
>>> benefit from this change.
>>>
>>> We have now more than 2 months to work on this.
>>>
>>
>> Hi
>>
>> Do you have any specific steps in mind? I'm not sure how we need to
>> prepare. Implementation, as described in DEP 0008
>> <https://github.com/django/deps/blob/main/accepted/0008-black.rst#reference-implementation>,
>> should be rather straightforward and I don't think anything needs to be
>> done in advance. We (Fellows and OPS team) should be able to implement it
>> within a few days.
>>
>> Best,
>> Mariusz
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django developers (Contributions to Django itself)" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-develop...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-developers/81687d6f-2ea3-44b4-a9c8-fab71e4e0843n%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-developers/81687d6f-2ea3-44b4-a9c8-fab71e4e0843n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-develop...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/CAMyDDM0kbb2aF%2BMK0GObXFm6pVrt%3DWMLsX1TcK6QyEHpDVBjeg%40mail.gmail.com.

Mariusz Felisiak

unread,
Oct 20, 2021, 3:50:55 PM10/20/21
to Django developers (Contributions to Django itself)
I was thinking we can start right now using black in a branch and see which issue will show up and start fixing them.

We don't want to merge multiple commits related to black. According to the "Implementation" section in DEP 0008, we're going to run Black on the entire Django code repository and make a single commit. Running black should not encounter any issues, it's a code formatter, unless we find any bugs in Black such as https://github.com/psf/black/issues/1629#issuecomment-700621526.

Best,
Mariusz


Paolo Melchiorre

unread,
Oct 20, 2021, 4:52:37 PM10/20/21
to django-d...@googlegroups.com
On Wed, Oct 20, 2021, 21:51 Mariusz Felisiak <felisiak...@gmail.com> wrote:
I was thinking we can start right now using black in a branch and see which issue will show up and start fixing them.

We don't want to merge multiple commits related to black. According to the "Implementation" section in DEP 0008, we're going to run Black on the entire Django code repository and make a single commit. Running black should not encounter any issues …

Okay, I also hope the migration to Black will be this smooth.

So now we just have to wait for 2022.

Ciao,
Paolo


Paolo Melchiorre

unread,
Jan 29, 2022, 4:24:42 PM1/29/22
to django-d...@googlegroups.com
Hi all,

Black 22.1.0 has just been released
https://github.com/psf/black/releases/tag/22.1.0

It seems the time has come to put DEP 0008 into practice and "run
Black on the entire Django code repository and make a single commit".

Ciao,
Paolo
--
Paolo Melchiorre

https://www.paulox.net

Markus Holtermann

unread,
Jan 29, 2022, 4:35:26 PM1/29/22
to Django developers
That's wonderful news. Thanks for the info, Paolo!

Cheers,

Markus
> --
> You received this message because you are subscribed to the Google
> Groups "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-develop...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/CAKFO%2Bx6dZAw7ftsGvJOV5crHazXLW4RST_t26JDHFcqA1uNXEA%40mail.gmail.com.

Mariusz Felisiak

unread,
Jan 31, 2022, 1:20:36 AM1/31/22
to Django developers (Contributions to Django itself)
Thanks. We will work on it later this week.
Reply all
Reply to author
Forward
0 new messages