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

Resolve #10949: use raise from in json_format.py #10966

Closed
wants to merge 4 commits into from
Closed

Resolve #10949: use raise from in json_format.py #10966

wants to merge 4 commits into from

Conversation

TommyDew42
Copy link
Contributor

Resolve #10949

@google-cla
Copy link

google-cla bot commented Nov 11, 2022

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@TommyDew42
Copy link
Contributor Author

TommyDew42 commented Nov 11, 2022

I noticed we don't have python unit tests. Why's that? Or I missed sth.

@zhangskz
Copy link
Member

You might be looking for https://github.com/protocolbuffers/protobuf/blob/main/python/google/protobuf/internal/json_format_test.py?

In general you can find python unit tests:

# Tests

raise TypeError(
'Can not find message descriptor by type_url: {0}'.format(type_url))
'Can not find message descriptor by type_url: {0}'.format(type_url)) from e
Copy link
Contributor

@jorgbrown jorgbrown Nov 16, 2022

Choose a reason for hiding this comment

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

This line is more than 80 columns wide; please shrink it. I suggest:

  • raise TypeError('Can not find message descriptor by type_url: {0}'.format(
  •   type_url)) from e
    

@@ -626,28 +626,28 @@ def _ConvertFieldValuePair(self, js, message, path):
'{0}.{1}'.format(path, name)))
except ParseError as e:
if field and field.containing_oneof is None:
raise ParseError('Failed to parse {0} field: {1}.'.format(name, e))
raise ParseError('Failed to parse {0} field: {1}.'.format(name, e)) from e
Copy link
Contributor

@jorgbrown jorgbrown Nov 16, 2022

Choose a reason for hiding this comment

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

This line is more than 80 columns wide; please shrink it. I suggest a line-break after the comma:

+          raise ParseError('Failed to parse {0} field: {1}.'.format(name,
+                                                                    e)) from e

Same for lines 633 and 635

raise ParseError(
'@type is missing when parsing any message at {0}'.format(path))
'@type is missing when parsing any message at {0}'.format(path)) from e
Copy link
Contributor

Choose a reason for hiding this comment

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

This line is more than 80 columns wide; please shrink it. I suggest a line-break before path:

+          '@type is missing when parsing any message at {0}'.format(
+              path)) from e

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@TommyDew42 TommyDew42 requested a review from a team as a code owner November 17, 2022 02:40
@TommyDew42 TommyDew42 requested review from anandolee and removed request for a team November 17, 2022 02:40
@TommyDew42
Copy link
Contributor Author

Seems the Linux Ruby Release CI check failed. It doesn't seem we have changes related to ruby in this PR. Can we rerun that again?

@TommyDew42
Copy link
Contributor Author

There isn't much information in the error page. Would the maintainers have more insight into the CI errors?

I thought the feature branch might be missing sth from the main so it caused the CI errors but my merging failed. How should we merge the master into the feature branch? 😢

@zhangskz
Copy link
Member

zhangskz commented Dec 5, 2022

There isn't much information in the error page. Would the maintainers have more insight into the CI errors?

I thought the feature branch might be missing sth from the main so it caused the CI errors but my merging failed. How should we merge the master into the feature branch? 😢

I believe the ruby error was failing on main and should be addressed now. Rerunning Kokoro, but I believe you may need to rebase your PR.

@TommyDew42
Copy link
Contributor Author

TommyDew42 commented Dec 5, 2022

I did a rebase. The Mergeable check is still failing. Is it because we have a merge commit? Should I erase that in the commit history?

And out of curiosity, why is merge not encouraged?

@zhangskz
Copy link
Member

zhangskz commented Dec 5, 2022

I did a rebase. The Mergeable check is still failing. Is it because we have a merge commit? Should I erase that in the commit history?

And out of curiosity, why is merge not encouraged?

You can ignore the Mergeable check -- that failure should always be present to remind Protobuf maintainers to not merge PRs directly and let our automated Copybara system handle merging changes in Github. This is because we land our changes internally first.

@TommyDew42
Copy link
Contributor Author

Do we need one more approval to unblock merging this PR? Tagging @jorgbrown to help!!

@TommyDew42
Copy link
Contributor Author

Would @acozzette be able to help review? All relevant changes in the PR is in python/google/protobuf/json_format.py!!

@TommyDew42 TommyDew42 changed the base branch from main to 2.7.0 December 14, 2022 03:15
@TommyDew42 TommyDew42 changed the base branch from 2.7.0 to main December 14, 2022 03:15
@TommyDew42
Copy link
Contributor Author

Undid the rebase by git reset and force push to make the PR reviewable again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use raise ... from e instead of raise ... only when catching error with try-except in python
6 participants