Skip to content
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

Upgrade RustPython #5192

Merged
merged 1 commit into from Jun 19, 2023
Merged

Upgrade RustPython #5192

merged 1 commit into from Jun 19, 2023

Conversation

charliermarsh
Copy link
Member

Summary

This PR upgrade RustPython to pull in the changes to Arguments (zip defaults with their identifiers) and all the renames to CmpOp and friends.

Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

This looks good to me. I am a bit concerned about all the new dependencies that the upgrade introduces and wonder if it could make sense to add helpers to Arguments to avoid the many chain in the user code (get all defaults, get all named arguments, get all positional arguments, get all arguments) etc.

Cargo.lock Outdated
@@ -198,6 +198,22 @@ version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6776fc96284a0bb647b615056fc496d1fe1644a7ab01829818a6d91cae888b84"

[[package]]
name = "block-buffer"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So many new dependencies. Are they all introduced because of the bigint library migration? Would it make sense for us to stay on numbigint for now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, but we are staying on num-bigint, aren't we? I'm not using the malachite feature.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does look like block-buffer comes from malachite. But does this actually affect the binary? I can also just remove the malachite stuff in a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I think rustpython_format doesn't have this properly gated as a feature. I'll fix this separately.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, fixed this. No new deps.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

for arg in &args.posonlyargs {
if let Some(expr) = &arg.annotation {
for arg_with_default in chain!(&args.posonlyargs, &args.args, &args.kwonlyargs) {
if let Some(expr) = &arg_with_default.def.annotation {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm another acronym with def. I should have catched that during the review. I guess that's fine for now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah don't love it.

Comment on lines 47 to 50
} in chain!(
&arguments.posonlyargs,
&arguments.args,
&arguments.kwonlyargs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the motivation for using chain! over iter.chain? I know we have a few use cases for itertools but I try to keep them to a minimum, in the hope, that we could someday remove the dependency.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can change it to iter.chain. I just wanted to be consistent everywhere and this was more concise.

def,
default: _,
range: _,
} in chain!(&arguments.posonlyargs, &arguments.args)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add some custom methods to arguments that allow you iterating over all arguments, over all defaults, etc? It feels very repetitive to have these chain calls sprinkled across the code base.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, maybe, I'm gonna punt it on now under "leave it better" (it's no worse than before).

crates/ruff_python_ast/src/visitor.rs Outdated Show resolved Hide resolved
crates/ruff_python_ast/src/visitor.rs Outdated Show resolved Hide resolved
crates/ruff_python_ast/src/visitor.rs Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

github-actions bot commented Jun 19, 2023

PR Check Results

Ecosystem

✅ ecosystem check detected no changes.

@charliermarsh charliermarsh force-pushed the charlie/upgrade branch 2 times, most recently from 83e127f to d1bbc6f Compare June 19, 2023 20:31
@charliermarsh charliermarsh enabled auto-merge (squash) June 19, 2023 20:58
@charliermarsh charliermarsh merged commit 36e01ad into main Jun 19, 2023
15 checks passed
@charliermarsh charliermarsh deleted the charlie/upgrade branch June 19, 2023 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants