-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add target_version
to formatter options
#9220
Conversation
#[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, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
|
Summary
This PR adds the
target_version
option to the formatter option and initializes it with thetarget_version
specified 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
dbg
statement toto_format_options
. Changes totarget-version
in the configuration were reflected in the debug printedPyFormatOptions
. Verified that usingrequires-python
works as intended.