-
Notifications
You must be signed in to change notification settings - Fork 26
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
chore: add lints to papyrus_common #1783
Conversation
All crates not inheriting from workspace lints fail the workspace lints and will be handled separately. Motivation: consistent linting across project and in the CI. Note: found an unrelated cargo doc bug in starknet_api_test_utils, not sure why this wasn't triggered thus far, lints are unrelated.
Lior banned `as` repo-wide, unless absolutely necessary. Nearly all `as` uses can be replaced with `[Try]From` which doesn't have implicit coercions like `as` (we encountered several bugs due to these coersions). Motivation: we are standardizing lints across the repo and CI, instead of each crate having separate sets of lints.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1783 +/- ##
===========================================
+ Coverage 40.10% 58.50% +18.40%
===========================================
Files 26 225 +199
Lines 1895 25938 +24043
Branches 1895 25938 +24043
===========================================
+ Hits 760 15176 +14416
- Misses 1100 9701 +8601
- Partials 35 1061 +1026 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @giladchase and @ShahakShama)
crates/papyrus_common/src/python_json.rs
line 46 at r1 (raw file):
write!(writer, r"\u{:4x}", num)?; } }
is this equivalent...? non-blocking
Suggestion:
match u8::try_from(ch) {
Ok(ascii) => writer.write_all(&[ascii])?,
Err(_) => {
let slice = ch.encode_utf16(&mut buf);
for num in slice {
write!(writer, r"\u{:4x}", num)?;
}
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ShahakShama)
crates/papyrus_common/src/python_json.rs
line 46 at r1 (raw file):
Previously, dorimedini-starkware wrote…
is this equivalent...? non-blocking
is_ascii
checks if 0<= char <= 127, whereas u8::try_from will succeed up to 255.
So, for example, for 128, in the original code, it'll encode it as utf16 (with \uX
escaped chars?), but in the proposed code, it will write it as is to the writer.
This could change expected output wherever this is used (it's related to Display
).
I'm not sure what was the original intention though without delving into this code (which is out of scope) unless @ShahakShama chimes in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @ShahakShama)
Lior banned
as
repo-wide, unless absolutely necessary.Nearly all
as
uses can be replaced with[Try]From
which doesn't have implicit coercions likeas
(we encountered several bugs due to these coersions).Motivation: we are standardizing lints across the repo and CI, instead of each crate having separate sets of lints.