Skip to content

implement str.translate and str.maketrans #943

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

Merged
merged 9 commits into from
May 12, 2019

Conversation

onsah
Copy link
Contributor

@onsah onsah commented May 9, 2019

Currently str.translate is working. This is my first contribution to this project so I would like to know if there is something wrong in my code.
Ref: #190

@@ -1104,4 +1139,34 @@ mod tests {
assert!(!PyString::from(s).istitle(&vm));
}
}

#[test]
fn str_translate() {
Copy link
Member

Choose a reason for hiding this comment

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

We also add python snippets under tests/snippets

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you using the latest rust toolchain?

You are right my default toolchain is stable which has different rustfmt than nightly. Now formatting with cargo +nightly fmt and it seems all formatting problemsa are fixed now!

@youknowone
Copy link
Member

Instead of manual formatting, run cargo fmt --all. The broken test is that one.

@onsah
Copy link
Contributor Author

onsah commented May 10, 2019

Instead of manual formatting, run cargo fmt --all. The broken test is that one.

I was already using cargo fmt.

@coolreader18
Copy link
Member

Are you using the latest rust toolchain?

whats_left.sh Outdated
@@ -8,4 +8,4 @@ python3 not_impl_gen.py

cd ..

cargo run -- tests/snippets/whats_left_to_implement.py
cargo +nightly run -- tests/snippets/whats_left_to_implement.py
Copy link
Contributor

Choose a reason for hiding this comment

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

Please leave this file as it is. Other people also depend upon this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I wasn't intented to push this change but I forgot that I changed it. I will revert it back with my next commit.

@windelbouwman
Copy link
Contributor

@Furyzer0 thank you for contributing to this project!

Copy link
Contributor

@windelbouwman windelbouwman left a comment

Choose a reason for hiding this comment

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

This change looks good to me!

@codecov-io
Copy link

codecov-io commented May 11, 2019

Codecov Report

Merging #943 into master will increase coverage by 0.08%.
The diff coverage is 47.14%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #943      +/-   ##
==========================================
+ Coverage   64.79%   64.87%   +0.08%     
==========================================
  Files          89       91       +2     
  Lines       15881    16271     +390     
  Branches     3587     3692     +105     
==========================================
+ Hits        10290    10556     +266     
- Misses       3231     3259      +28     
- Partials     2360     2456      +96
Impacted Files Coverage Δ
vm/src/obj/objstr.rs 73.31% <47.14%> (-2.29%) ⬇️
vm/src/sysmodule.rs 58.46% <0%> (-7%) ⬇️
vm/src/obj/objint.rs 84.56% <0%> (-2.1%) ⬇️
vm/src/import.rs 73.58% <0%> (-1.42%) ⬇️
vm/src/obj/objbyteinner.rs 74.43% <0%> (-0.93%) ⬇️
src/main.rs 22.53% <0%> (-0.87%) ⬇️
vm/src/obj/objbytearray.rs 78.61% <0%> (-0.67%) ⬇️
vm/src/obj/objbytes.rs 77.21% <0%> (-0.28%) ⬇️
vm/src/pyobject.rs 78.24% <0%> (-0.09%) ⬇️
vm/src/stdlib/mod.rs 100% <0%> (ø) ⬆️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 76a0020...04c017d. Read the comment docs.

@onsah
Copy link
Contributor Author

onsah commented May 11, 2019

It seems both functions work and all tests have passed. Tomorrow I will add the unit test for str.maketrans in the Rust module then it can be merged if there is no problem with the code.

@windelbouwman windelbouwman merged commit 878cc3b into RustPython:master May 12, 2019
@onsah onsah changed the title [WIP] implement str.translate and str.maketrans implement str.translate and str.maketrans May 13, 2019
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.

6 participants