#35308: FileNotFoundError escapes from run_formatters()
-------------------------------+--------------------------------------
Reporter: Jacob Walls | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 4.2
Severity: Normal | Resolution:
Keywords: black | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Description changed by Jacob Walls:
Old description:
> 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. :-)
New description:
A couple coworkers of mine 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#comment:1>
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/0107018e43cb624d-79aadedc-84e9-4890-848a-188bfaf2a283-000000%40eu-central-1.amazonses.com.