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

Translate types.md to Japanese #554

Merged
merged 2 commits into from
Jun 18, 2024

Conversation

K-dash
Copy link
Contributor

@K-dash K-dash commented Jun 17, 2024

Related to #545

types.mdの日本語版Docを作成しました。

確認と相談

脚注の5(Optional型)のリンクが存在しなかったため、暫定的に脚注6(Union型)のexamples/union.pyへのリンクを差し込みました。
こちら、脚注5(Optional型)のexampleが存在しないのは意図されているものでしょうか?
もし意図されていない場合、examplesのunion.py内に以下のような簡単なOptional型の例を追加するのはいかがでしょうか?
(OptionalはNoneとのUnionなので、Optionalのexampleを新規に作るのは仰々しいかなと思った次第です)

from serde import serde
from serde.json import from_json, to_json


@serde
class Bar:
    v: int


@serde
class Baz:
    v: float


@serde
class Foo:
    a: int | str
    b: dict[str, int] | list[int]
    c: Bar | Baz
    d: Baz | Bar | None  # Optional


def main() -> None:
    f = Foo(10, [1, 2, 3], Bar(10), None)
    print(f"Into Json: {to_json(f)}")

    s = '{"a": 10, "b": [1, 2, 3], "c": {"Bar": {"v": 10}}}'
    print(f"From Json: {from_json(Foo, s)}")

    f = Foo("foo", {"bar": 1, "baz": 2}, Baz(100.0), Baz(200.0))
    print(f"Into Json: {to_json(f)}")

    s = '{"a": "foo", "b": {"bar": 1, "baz": 2}, "c": {"Baz": {"v": 100.0}}, "d": {"Bar": {"v": 200}}}'
    print(f"From Json: {from_json(Foo, s)}")


if __name__ == "__main__":
    main()

レビューをお願いします 🙏

Copy link

codecov bot commented Jun 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.04%. Comparing base (ac3c68f) to head (f3576af).
Report is 13 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #554   +/-   ##
=======================================
  Coverage   91.04%   91.04%           
=======================================
  Files          13       13           
  Lines        1942     1942           
  Branches      437      437           
=======================================
  Hits         1768     1768           
  Misses        117      117           
  Partials       57       57           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yukinarit yukinarit added the documentation Improvements or additions to documentation label Jun 18, 2024
@yukinarit
Copy link
Owner

examplesのunion.py内に以下のような簡単なOptional型の例を追加するのはいかがでしょうか?

賛成です 🙌

Copy link
Owner

@yukinarit yukinarit left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

@yukinarit yukinarit merged commit 2824555 into yukinarit:main Jun 18, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants