Add target_version to formatter options#9220
Merged
Merged
Conversation
MichaReiser
commented
Dec 21, 2023
Comment on lines
+368
to
+383
| #[derive(CacheKey, Clone, Copy, Debug, PartialOrd, Ord, PartialEq, Eq, Default)] | ||
| #[cfg_attr( | ||
| feature = "serde", | ||
| derive(serde::Serialize, serde::Deserialize), | ||
| serde(rename_all = "lowercase") | ||
| )] | ||
| #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] | ||
| pub enum PythonVersion { | ||
| Py37, | ||
| #[default] | ||
| Py38, | ||
| Py39, | ||
| Py310, | ||
| Py311, | ||
| Py312, | ||
| } |
Member
Author
There was a problem hiding this comment.
It would be nice if we could have a single PythonVersion definitions shared by the linter and formatter but there's currently no good crate where to place it. Creating one feels overkill for such a simple definition.
Ultimately I think the definition should be in ruff_python_ast where it specifies the language features.
6bc4c0f to
37ddbea
Compare
Contributor
|
dhruvmanila
approved these changes
Dec 21, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR adds the
target_versionoption to the formatter option and initializes it with thetarget_versionspecified in theruff.toml.The new configuration doesn't yet affect any formatting.
Test Plan
I ran ruff manually in my test project and added a
dbgstatement toto_format_options. Changes totarget-versionin the configuration were reflected in the debug printedPyFormatOptions. Verified that usingrequires-pythonworks as intended.