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

chore: add lints to papyrus_common #1783

Merged
merged 2 commits into from
Nov 4, 2024
Merged

Conversation

giladchase
Copy link
Contributor

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.

Gilad Chase added 2 commits November 4, 2024 11:28
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.
@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link

codecov bot commented Nov 4, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 58.50%. Comparing base (e3165c4) to head (3795db5).
Report is 180 commits behind head on main.

Files with missing lines Patch % Lines
crates/papyrus_common/src/python_json.rs 0.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware left a 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)?;
                }
                }
            }

@giladchase giladchase deleted the branch main November 4, 2024 13:59
@giladchase giladchase closed this Nov 4, 2024
@giladchase giladchase reopened this Nov 4, 2024
Base automatically changed from gilad/free-lints to main November 4, 2024 13:59
Copy link
Contributor Author

@giladchase giladchase left a 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.

Copy link
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ShahakShama)

@giladchase giladchase merged commit 7e95594 into main Nov 4, 2024
34 of 46 checks passed
@giladchase giladchase deleted the gilad/papyrus-common-lints branch November 4, 2024 14:41
@github-actions github-actions bot locked and limited conversation to collaborators Nov 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants