Skip to content

Commit

Permalink
use kebab-case
Browse files Browse the repository at this point in the history
  • Loading branch information
ntBre committed Feb 26, 2025
1 parent e82b83a commit f854172
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# parse_options: { "target_version": "3.9" }
# parse_options: { "target-version": "3.9" }
match 2:
case 1:
pass
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# parse_options: { "target_version": "3.10" }
# parse_options: { "target-version": "3.10" }
match 2:
case 1:
pass
2 changes: 1 addition & 1 deletion crates/ruff_python_parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ impl FusedIterator for TokenIterWithContext<'_> {}
#[cfg_attr(
feature = "serde",
derive(serde::Deserialize),
serde(rename_all = "lowercase")
serde(rename_all = "kebab-case")
)]
pub enum Mode {
/// The code consists of a sequence of statements.
Expand Down
6 changes: 5 additions & 1 deletion crates/ruff_python_parser/src/parser/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ use crate::{AsMode, Mode};
/// let options = ParseOptions::from(PySourceType::Python);
/// ```
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
#[cfg_attr(
feature = "serde",
derive(serde::Deserialize),
serde(rename_all = "kebab-case")
)]
pub struct ParseOptions {
/// Specify the mode in which the code will be parsed.
#[cfg_attr(feature = "serde", serde(default = "default_mode"))]
Expand Down
4 changes: 2 additions & 2 deletions crates/ruff_python_parser/src/parser/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2266,13 +2266,13 @@ impl<'src> Parser<'src> {
let cases = self.parse_match_body();

// test_err match_before_py310
// # parse_options: { "target_version": "3.9" }
// # parse_options: { "target-version": "3.9" }
// match 2:
// case 1:
// pass

// test_ok match_after_py310
// # parse_options: { "target_version": "3.10" }
// # parse_options: { "target-version": "3.10" }
// match 2:
// case 1:
// pass
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff_python_parser/tests/fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ fn test_invalid_syntax(input_path: &Path) {
/// For example,
///
/// ```python
/// # parse_options: { "target_version": "3.10" }
/// # parse_options: { "target-version": "3.10" }
/// def f(): ...
fn extract_options(source: &str) -> Option<ParseOptions> {
// extract options from pragma on the first line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Module(
## Unsupported Syntax Errors

|
1 | # parse_options: { "target_version": "3.9" }
1 | # parse_options: { "target-version": "3.9" }
2 | match 2:
| ^^^^^ Syntax Error: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)
3 | case 1:
Expand Down

0 comments on commit f854172

Please sign in to comment.