FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Update Ruff to 0.16.5 (#8617) · theFestest/RustPython@96925f4 · GitHub

Repository navigation

Commit 96925f4

Browse files
authored
Update Ruff to 0.16.5 (RustPython#8617)
Pin the RustPython Ruff fork to the patch commit based on Ruff 0.16.5 and adapt compiler and AST integration to the updated APIs. Assisted-by: Codex:GPT-5
1 parent 531cf2b commit 96925f4

20 files changed

Lines changed: 217 additions & 91 deletions

File tree

‎.github/workflows/ci.yaml‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ jobs:
9797

9898
- uses: dtolnay/rust-toolchain@stable
9999

100+
- name: Use a short Cargo home on Windows
101+
if: runner.os == 'Windows'
102+
shell: pwsh
103+
run: |
104+
"CARGO_HOME=$env:RUNNER_TEMP\c" >> $env:GITHUB_ENV
105+
git config --global core.longpaths true
106+
100107
- name: Restore cache
101108
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
102109
with:
@@ -105,6 +112,9 @@ jobs:
105112
~/.cargo/registry/index/
106113
~/.cargo/registry/cache/
107114
~/.cargo/git/db/
115+
${{ runner.temp }}/c/registry/index/
116+
${{ runner.temp }}/c/registry/cache/
117+
${{ runner.temp }}/c/git/db/
108118
target/
109119
key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-
110120
restore-keys: |
@@ -338,6 +348,13 @@ jobs:
338348

339349
- uses: dtolnay/rust-toolchain@stable
340350

351+
- name: Use a short Cargo home on Windows
352+
if: runner.os == 'Windows'
353+
shell: pwsh
354+
run: |
355+
"CARGO_HOME=$env:RUNNER_TEMP\c" >> $env:GITHUB_ENV
356+
git config --global core.longpaths true
357+
341358
- name: Restore cache
342359
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
343360
with:
@@ -346,6 +363,9 @@ jobs:
346363
~/.cargo/registry/index/
347364
~/.cargo/registry/cache/
348365
~/.cargo/git/db/
366+
${{ runner.temp }}/c/registry/index/
367+
${{ runner.temp }}/c/registry/cache/
368+
${{ runner.temp }}/c/git/db/
349369
target/
350370
key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-
351371
restore-keys: |
@@ -499,6 +519,13 @@ jobs:
499519
with:
500520
components: clippy
501521

522+
- name: Use a short Cargo home on Windows
523+
if: runner.os == 'Windows'
524+
shell: pwsh
525+
run: |
526+
"CARGO_HOME=$env:RUNNER_TEMP\c" >> $env:GITHUB_ENV
527+
git config --global core.longpaths true
528+
502529
- name: Restore cache
503530
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
504531
with:
@@ -507,6 +534,9 @@ jobs:
507534
~/.cargo/registry/index/
508535
~/.cargo/registry/cache/
509536
~/.cargo/git/db/
537+
${{ runner.temp }}/c/registry/index/
538+
${{ runner.temp }}/c/registry/cache/
539+
${{ runner.temp }}/c/git/db/
510540
target/
511541
key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-
512542
restore-keys: |

‎.github/workflows/release.yml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ jobs:
6060
with:
6161
target: ${{ matrix.target }}
6262

63+
- name: Use a short Cargo home on Windows
64+
if: runner.os == 'Windows'
65+
shell: pwsh
66+
run: |
67+
"CARGO_HOME=$env:RUNNER_TEMP\c" >> $env:GITHUB_ENV
68+
git config --global core.longpaths true
69+
6370
- name: Install macOS dependencies
6471
uses: ./.github/actions/install-macos-deps
6572
with:

‎.github/workflows/update-caches.yml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ jobs:
5252
toolchain: ${{ matrix.toolchain }}
5353
target: ${{ matrix.target }}
5454

55+
- name: Use a short Cargo home on Windows
56+
if: runner.os == 'Windows'
57+
shell: pwsh
58+
run: |
59+
"CARGO_HOME=$env:RUNNER_TEMP\c" >> $env:GITHUB_ENV
60+
git config --global core.longpaths true
61+
5562
- name: Install macos dependencies
5663
uses: ./.github/actions/install-macos-deps
5764
with:
@@ -74,5 +81,8 @@ jobs:
7481
~/.cargo/registry/index/
7582
~/.cargo/registry/cache/
7683
~/.cargo/git/db/
84+
${{ runner.temp }}/c/registry/index/
85+
${{ runner.temp }}/c/registry/cache/
86+
${{ runner.temp }}/c/git/db/
7787
target/
7888
key: ${{ runner.os }}-${{ matrix.toolchain }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('Cargo.lock') }}-${{ github.sha }}

‎Cargo.lock‎

Lines changed: 58 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,10 @@ rustpython-wtf8 = { path = "crates/wtf8", version = "0.5.0" }
184184
rustpython-doc = { path = "crates/doc", version = "0.5.0" }
185185

186186
# Use the RustPython Ruff fork for RustPython public `_ast` metadata.
187-
ruff_python_parser = { package = "rustpython-ruff_python_parser", git = "https://github.com/RustPython/ruff.git", tag = "0.15.19-rustpython" }
188-
ruff_python_ast = { package = "rustpython-ruff_python_ast", git = "https://github.com/RustPython/ruff.git", tag = "0.15.19-rustpython" }
189-
ruff_text_size = { package = "rustpython-ruff_text_size", git = "https://github.com/RustPython/ruff.git", tag = "0.15.19-rustpython" }
190-
ruff_source_file = { package = "rustpython-ruff_source_file", git = "https://github.com/RustPython/ruff.git", tag = "0.15.19-rustpython" }
187+
ruff_python_parser = { package = "rustpython-ruff_python_parser", git = "https://github.com/RustPython/ruff.git", tag = "0.16.5-rustpython" }
188+
ruff_python_ast = { package = "rustpython-ruff_python_ast", git = "https://github.com/RustPython/ruff.git", tag = "0.16.5-rustpython" }
189+
ruff_text_size = { package = "rustpython-ruff_text_size", git = "https://github.com/RustPython/ruff.git", tag = "0.16.5-rustpython" }
190+
ruff_source_file = { package = "rustpython-ruff_source_file", git = "https://github.com/RustPython/ruff.git", tag = "0.16.5-rustpython" }
191191

192192
der = { version = "0.8", features = ["alloc", "oid", "pem", "zeroize"] }
193193
phf = { version = "0.14.0", default-features = false, features = ["macros"]}

‎Lib/test/test_syntax.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,7 @@
14681468
Traceback (most recent call last):
14691469
SyntaxError: invalid syntax
14701470
1471-
>>> dict(x=34, x=1, y=2); x $ y # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1471+
>>> dict(x=34, x=1, y=2); x $ y
14721472
Traceback (most recent call last):
14731473
SyntaxError: invalid syntax
14741474

‎crates/codegen/src/compile.rs‎

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use malachite_bigint::BigInt;
2424
use num_complex::Complex;
2525
use num_traits::{Num, ToPrimitive, Zero};
2626
use ruff_python_ast::{self as ast, name::Name};
27-
use ruff_text_size::{Ranged, TextRange, TextSize};
27+
use ruff_text_size::{Ranged, TextRange, TextSize, TextSlice};
2828
use rustpython_compiler_core::{
2929
Mode, OneIndexed, PositionEncoding, SourceFile, SourceLocation,
3030
bytecode::{
@@ -9129,7 +9129,12 @@ impl<'warnings> Compiler<'warnings> {
91299129
range,
91309130
..
91319131
}) => {
9132-
let key = key.as_ref();
9132+
let Some(key) = key.as_deref() else {
9133+
self.set_source_range(*range);
9134+
return Err(self.error(CodegenErrorType::SyntaxError(
9135+
"dict unpacking cannot be used in dict comprehension".to_owned(),
9136+
)));
9137+
};
91339138
self.compile_comprehension(
91349139
"<dictcomp>",
91359140
Some(
@@ -9644,7 +9649,11 @@ impl<'warnings> Compiler<'warnings> {
96449649
continue;
96459650
};
96469651
for other in &keywords[i + 1..] {
9647-
if other.arg.as_ref() == Some(arg) {
9652+
if other
9653+
.arg
9654+
.as_ref()
9655+
.is_some_and(|other| other.as_str() == arg.as_str())
9656+
{
96489657
return Err(self.error_ranged(
96499658
CodegenErrorType::SyntaxError(format!("keyword argument repeated: {arg}")),
96509659
other.range,
@@ -10067,7 +10076,11 @@ impl<'warnings> Compiler<'warnings> {
1006710076
self.visit_expr(&first.iter);
1006810077
}
1006910078
if self.consume_inlined_comprehension_scope() {
10070-
self.visit_comprehension_tail(key, Some(value), generators);
10079+
if let Some(key) = key.as_deref() {
10080+
self.visit_comprehension_tail(key, Some(value), generators);
10081+
} else {
10082+
self.visit_comprehension_tail(value, None, generators);
10083+
}
1007110084
} else {
1007210085
self.consume_scope();
1007310086
}
@@ -13249,9 +13262,10 @@ impl<'warnings> Compiler<'warnings> {
1324913262
{
1325013263
let after_brace = interp.range.start() + TextSize::new(1);
1325113264
self.source_file
13265+
.source_text()
1325213266
.slice(TextRange::new(after_brace, expr_range.end()))
1325313267
} else {
13254-
self.source_file.slice(expr_range)
13268+
self.source_file.source_text().slice(expr_range)
1325513269
}
1325613270
.to_string();
1325713271
self.set_source_range(interp.range);
@@ -13843,7 +13857,7 @@ mod tests {
1384313857
fn frozenset_call_expr() -> ast::Expr {
1384413858
ast::Expr::Call(ast::ExprCall {
1384513859
node_index: ast::AtomicNodeIndex::NONE,
13846-
range: TextRange::default(),
13860+
range_start: TextSize::default(),
1384713861
func: Box::new(ast::Expr::Name(ast::ExprName {
1384813862
node_index: ast::AtomicNodeIndex::NONE,
1384913863
range: TextRange::default(),
@@ -13996,7 +14010,7 @@ mod tests {
1399614010
);
1399714011
let message = first_ast_constant_warning(ast::Expr::Call(ast::ExprCall {
1399814012
node_index: ast::AtomicNodeIndex::NONE,
13999-
range: TextRange::default(),
14013+
range_start: TextSize::default(),
1400014014
func: Box::new(func),
1400114015
arguments: ast::Arguments {
1400214016
node_index: ast::AtomicNodeIndex::NONE,

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL