#35308: FileNotFoundError escapes from run_formatters()
-----------------------------------------+------------------------
               Reporter:  Jacob Walls    |          Owner:  nobody
                   Type:  Bug            |         Status:  new
              Component:  Uncategorized  |        Version:  4.2
               Severity:  Normal         |       Keywords:  black
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 Two members of my team have now run into
 [https://forum.djangoproject.com/t/black-library-error/20897/3 this issue]
 described on the Django forum.

 In essence, it's not safe to assume that just because
 `shutil.which("black")` returns a path that `subprocess.run()` can execute
 that path.

 Some [https://docs.python.org/3/library/shutil.html#shutil.which
 complications] with `shutil.which(..., path=None)`:
 - Reads a path variable from one or two fallbacks (either os.environ() or
 os.defpath)
 - Behavior is different on Windows
 - Behavior is different on Windows with Python 3.12.0
 - Behavior is different on Windows with Python 3.12.1

 My impression of the feature was that it was aiming at a frictionless
 experience -- format if you have a working black install, don't if you
 don't.

 Suggesting we should catch `FileNotFoundError` (at least) and at most log
 out an explanation why the file wasn't formatted. Users who only have a
 copy of black in abandoned environments are unlikely to care about their
 files not being formatted. :-)
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35308>
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/0107018e43c411e5-765707fc-ba07-4f4f-a5cc-90813b34c8e8-000000%40eu-central-1.amazonses.com.

Reply via email to