Skip to content

Python: add datetime support + pass mypy --strict + rename JSON-related methods #14

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 2 commits into from
Mar 13, 2021

Conversation

ucarion
Copy link
Contributor

@ucarion ucarion commented Mar 11, 2021

This PR introduces a few changes:

  • Renames to_json and from_json on generated classes to to_json_data and from_json_data. From experience with the Ruby code generation, these names are less likely to lead to confusion. The functions work with data that conforms to the JSON data model, not JSON strings itself.
  • Instead of emitting str for a JTD timestamp, this PR has us emit a Python3 datetime.datetime.
  • Refactors generated code to always be compatible with mypy --strict. This is tested as part of the Docker testing regime.
  • Makes Python-specific modifications to custom-overrides.jtd.json to make the result type-check against mypy.
  • Moves utility functions to the end of the file using the new Postamble codegen functionality. _parse_rfc339 is added as a utility.

Also, this PR includes cargo fmt. This leads to some noisy diff across a few targets.

@ucarion ucarion merged commit 46f8289 into master Mar 13, 2021
@ucarion ucarion deleted the ucarion/python-datetime branch March 13, 2021 01:11
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.

1 participant