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

Fix pydantic Unions type conversion #160

Merged
merged 4 commits into from
Mar 22, 2021

Conversation

danixeee
Copy link
Contributor

@danixeee danixeee commented Mar 22, 2021

Description (e.g. "Related to ...", etc.)

Closes #159.

The reason I couldn't do this:

class JsonRPCRequestMessage(JsonRpcMessage):
    """A class that represents json rpc request message."""
    id: Union[int,str]
    method: str
    params: Any

is that in the case of Union, pydantic tries to convert the input to the first valid type, so, if you pass id='1', an object will have a field of type int id=1...

Code review checklist (for code reviewer to complete)

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR)
  • Title summarizes what is changing
  • Commit messages are meaningful (see this for details)
  • Tests have been included and/or updated, as appropriate
  • Docstrings have been included and/or updated, as appropriate
  • Standalone docs have been updated accordingly
  • CONTRIBUTORS.md was updated, as appropriate
  • Changelog has been updated, as needed (see CHANGELOG.md)

@danixeee danixeee added bug Something isn't working upstream Something needs to be done upstream labels Mar 22, 2021
@danixeee danixeee requested a review from renatav March 22, 2021 12:31
@renatav renatav merged commit e2cefae into master Mar 22, 2021
@renatav renatav deleted the danixeee/resp-req-msg-id-field-fix branch March 22, 2021 17:18
@muffinmad
Copy link
Contributor

Is it possible to make release for this change?

@danixeee
Copy link
Contributor Author

Sure, once we merge #163 I will do the point release.

@danixeee
Copy link
Contributor Author

@muffinmad v0.10.2 is released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream Something needs to be done upstream
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Type of the id field in response message
3 participants