Skip to content

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

Merged
ucarion merged 2 commits into
masterfrom
ucarion/python-datetime
Mar 13, 2021
Merged

ucarion merged 2 commits into
masterfrom
ucarion/python-datetime

Conversation

@ucarion

@ucarion ucarion commented Mar 11, 2021 •

Copy link
Copy Markdown
Contributor

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