New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Infer target version based on project metadata #3219
Merged
Merged
+203
−9
Commits on Jan 19, 2023
Commits on Jan 31, 2023
-
Try 3.10 grammar more often + remove redundant out()
Say you're attrs and you don't configure target-version. Previously Black would default to trying every single grammar it has, including the 3.10 grammar. With this PR, now target-version is configured for you effectively so now get_grammars() is more selective in which grammars it returns. If any target versions don't support the match statement, the 3.10 grammar won't be tried. And while in theory a 3.7+ project shoudn't be using 3.10 features, attrs has a test file which uses match (which fails to parse because the 3.10 grammar isn't selected). To avoid breaking attrs, get_grammars() will now return the 3.10 grammar as long as *any* the target versions support match. The out() call was made redundant by an older PR that prints the configuration if --verbose is passed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.