Warn (or error) if targeting a higher version of Python than the one Black is running on #3144
Labels
C: parser
How we parse code. Or fail to parse it.
C: target version
Related to --target-version, e.g. autodetection
T: enhancement
New feature or request
Is your feature request related to a problem? Please describe.
When formatting a file whose syntax requires a higher version of Python than the one Black is running on, Black fails (with a
cannot use --safe with this file
error). This is made more confusing because Black only fails when changes are made. If no changes are made, then everything seems to be OK and I won't ever know that the environment is faulty.Describe the solution you'd like
It's still unclear whether target-version is an exact list of Python versions or just a minimum to target (see GH-751) but it would be dumb to check all of the target versions specified since many projects currently specify all of the Pythons they support (including us). We can only check the lowest specified which in a way kinda decides GH-751 for us.
It was also suggested to check the autodetected target version too. This is both easier and harder since there's only one target version to check (we get to avoid GH-751) but OTOH, we will probably want to warn only once which is a chore with multiprocessing.
Describe alternatives you've considered
--fast
skipping the AST equivalence checkAdditional context
See also GH-3143 for additional discussion.
The text was updated successfully, but these errors were encountered: