#34085: Black shouldn't format non-Python files
-------------------------------------+-------------------------------------
     Reporter:  Jeff Triplett        |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Core (Management     |                  Version:  4.1
  commands)                          |
     Severity:  Normal               |               Resolution:
     Keywords:  startproject black   |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson):

 Hey Jeff.

 > It's a .in (no extra i) that Django seems to be passing through to Black
 somehow. I have used Black for years and I have never had either file
 extension processed by Black.

 So this behaviour changed somewhere between black `21.10b0` and `22.10.0`
 — I'm wondering who you know who might be able to point to where that was?
 Django passes the written files to black (.png .txt files and so on, as
 well as .py). Black handles these well, and **was** doing the same for
 `.in` but not now. So 🤔

 It **looks** like we might be able to pass the project dir here with this
 kind of diff:


 {{{
 (django) carlton@Carltons-MacBook-Pro tests % git diff
 diff --git a/django/core/management/templates.py
 b/django/core/management/templates.py
 index 71ee0a6ce8..5ee3664f77 100644
 --- a/django/core/management/templates.py
 +++ b/django/core/management/templates.py
 @@ -232,7 +232,7 @@ class TemplateCommand(BaseCommand):
                  else:
                      shutil.rmtree(path_to_remove)

 -        run_formatters(self.written_files, **formatter_paths)
 +        run_formatters([top_dir], **formatter_paths)

      def handle_template(self, template, subdir):
          """
 }}}

 Then Black goes back to not processing the `.in` file. It looks as if
 directories are walked, and filtered for whether black thinks it can
 process them, whereas explicit files are attempted regardless.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34085#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070183cb36661b-5c48615b-020c-4e5c-ac78-e3fa5d08298a-000000%40eu-central-1.amazonses.com.

Reply via email to