Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ jobs:

- uses: dtolnay/rust-toolchain@stable

- name: Use a short Cargo home on Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
"CARGO_HOME=$env:RUNNER_TEMP\c" >> $env:GITHUB_ENV
git config --global core.longpaths true

- name: Restore cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
Expand All @@ -105,6 +112,9 @@ jobs:
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
${{ runner.temp }}/c/registry/index/
${{ runner.temp }}/c/registry/cache/
${{ runner.temp }}/c/git/db/
target/
key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-
restore-keys: |
Expand Down Expand Up @@ -338,6 +348,13 @@ jobs:

- uses: dtolnay/rust-toolchain@stable

- name: Use a short Cargo home on Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
"CARGO_HOME=$env:RUNNER_TEMP\c" >> $env:GITHUB_ENV
git config --global core.longpaths true

- name: Restore cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
Expand All @@ -346,6 +363,9 @@ jobs:
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
${{ runner.temp }}/c/registry/index/
${{ runner.temp }}/c/registry/cache/
${{ runner.temp }}/c/git/db/
target/
key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-
restore-keys: |
Expand Down Expand Up @@ -499,6 +519,13 @@ jobs:
with:
components: clippy

- name: Use a short Cargo home on Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
"CARGO_HOME=$env:RUNNER_TEMP\c" >> $env:GITHUB_ENV
git config --global core.longpaths true

- name: Restore cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
Expand All @@ -507,6 +534,9 @@ jobs:
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
${{ runner.temp }}/c/registry/index/
${{ runner.temp }}/c/registry/cache/
${{ runner.temp }}/c/git/db/
target/
key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-
restore-keys: |
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ jobs:
with:
target: ${{ matrix.target }}

- name: Use a short Cargo home on Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
"CARGO_HOME=$env:RUNNER_TEMP\c" >> $env:GITHUB_ENV
git config --global core.longpaths true

- name: Install macOS dependencies
uses: ./.github/actions/install-macos-deps
with:
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/update-caches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ jobs:
toolchain: ${{ matrix.toolchain }}
target: ${{ matrix.target }}

- name: Use a short Cargo home on Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
"CARGO_HOME=$env:RUNNER_TEMP\c" >> $env:GITHUB_ENV
git config --global core.longpaths true

- name: Install macos dependencies
uses: ./.github/actions/install-macos-deps
with:
Expand All @@ -74,5 +81,8 @@ jobs:
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
${{ runner.temp }}/c/registry/index/
${{ runner.temp }}/c/registry/cache/
${{ runner.temp }}/c/git/db/
target/
key: ${{ runner.os }}-${{ matrix.toolchain }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('Cargo.lock') }}-${{ github.sha }}
79 changes: 58 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ rustpython-wtf8 = { path = "crates/wtf8", version = "0.5.0" }
rustpython-doc = { path = "crates/doc", version = "0.5.0" }

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

der = { version = "0.8", features = ["alloc", "oid", "pem", "zeroize"] }
phf = { version = "0.14.0", default-features = false, features = ["macros"]}
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,7 @@
Traceback (most recent call last):
SyntaxError: invalid syntax

>>> dict(x=34, x=1, y=2); x $ y # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> dict(x=34, x=1, y=2); x $ y
Traceback (most recent call last):
SyntaxError: invalid syntax

Expand Down
28 changes: 21 additions & 7 deletions crates/codegen/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use malachite_bigint::BigInt;
use num_complex::Complex;
use num_traits::{Num, ToPrimitive, Zero};
use ruff_python_ast::{self as ast, name::Name};
use ruff_text_size::{Ranged, TextRange, TextSize};
use ruff_text_size::{Ranged, TextRange, TextSize, TextSlice};
use rustpython_compiler_core::{
Mode, OneIndexed, PositionEncoding, SourceFile, SourceLocation,
bytecode::{
Expand Down Expand Up @@ -9129,7 +9129,12 @@ impl<'warnings> Compiler<'warnings> {
range,
..
}) => {
let key = key.as_ref();
let Some(key) = key.as_deref() else {
self.set_source_range(*range);
return Err(self.error(CodegenErrorType::SyntaxError(
"dict unpacking cannot be used in dict comprehension".to_owned(),
)));
};
self.compile_comprehension(
"<dictcomp>",
Some(
Expand Down Expand Up @@ -9644,7 +9649,11 @@ impl<'warnings> Compiler<'warnings> {
continue;
};
for other in &keywords[i + 1..] {
if other.arg.as_ref() == Some(arg) {
if other
.arg
.as_ref()
.is_some_and(|other| other.as_str() == arg.as_str())
{
return Err(self.error_ranged(
CodegenErrorType::SyntaxError(format!("keyword argument repeated: {arg}")),
other.range,
Expand Down Expand Up @@ -10067,7 +10076,11 @@ impl<'warnings> Compiler<'warnings> {
self.visit_expr(&first.iter);
}
if self.consume_inlined_comprehension_scope() {
self.visit_comprehension_tail(key, Some(value), generators);
if let Some(key) = key.as_deref() {
self.visit_comprehension_tail(key, Some(value), generators);
} else {
self.visit_comprehension_tail(value, None, generators);
}
} else {
self.consume_scope();
}
Expand Down Expand Up @@ -13249,9 +13262,10 @@ impl<'warnings> Compiler<'warnings> {
{
let after_brace = interp.range.start() + TextSize::new(1);
self.source_file
.source_text()
.slice(TextRange::new(after_brace, expr_range.end()))
} else {
self.source_file.slice(expr_range)
self.source_file.source_text().slice(expr_range)
}
.to_string();
self.set_source_range(interp.range);
Expand Down Expand Up @@ -13843,7 +13857,7 @@ mod tests {
fn frozenset_call_expr() -> ast::Expr {
ast::Expr::Call(ast::ExprCall {
node_index: ast::AtomicNodeIndex::NONE,
range: TextRange::default(),
range_start: TextSize::default(),
func: Box::new(ast::Expr::Name(ast::ExprName {
node_index: ast::AtomicNodeIndex::NONE,
range: TextRange::default(),
Expand Down Expand Up @@ -13996,7 +14010,7 @@ mod tests {
);
let message = first_ast_constant_warning(ast::Expr::Call(ast::ExprCall {
node_index: ast::AtomicNodeIndex::NONE,
range: TextRange::default(),
range_start: TextSize::default(),
func: Box::new(func),
arguments: ast::Arguments {
node_index: ast::AtomicNodeIndex::NONE,
Expand Down
Loading
Loading