diff --git a/CHANGELOG.md b/CHANGELOG.md index a38d8958..6ac6d051 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +### [1.10.2](https://www.github.com/googleapis/proto-plus-python/compare/v1.10.1...v1.10.2) (2020-10-14) + + +### Documentation + +* explain how to use repeated struct.Value ([#148](https://www.github.com/googleapis/proto-plus-python/issues/148)) ([9634ea8](https://www.github.com/googleapis/proto-plus-python/commit/9634ea8fa464c0d34f13469016f23cc2e986d973)), closes [#104](https://www.github.com/googleapis/proto-plus-python/issues/104) + ### [1.10.1](https://www.github.com/googleapis/proto-plus-python/compare/v1.10.0...v1.10.1) (2020-10-08) diff --git a/docs/conf.py b/docs/conf.py index 6a455085..4c77371e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -15,6 +15,9 @@ import os import sys +import pkg_resources + + sys.path.insert(0, os.path.abspath("..")) @@ -22,12 +25,9 @@ project = "Proto Plus for Python" copyright = "2018, Google LLC" -author = "Luke Sneeringer" +author = "Google LLC" -# The short X.Y version -version = "0.1.0" -# The full version, including alpha/beta/rc tags -release = "0.1.0" +version = pkg_resources.get_distribution("proto-plus").version # -- General configuration --------------------------------------------------- diff --git a/docs/fields.rst b/docs/fields.rst index b4aa2425..07e70fbf 100644 --- a/docs/fields.rst +++ b/docs/fields.rst @@ -56,6 +56,36 @@ Declare them in Python using the :class:`~.RepeatedField` class: publisher = proto.Field(proto.STRING, number=2) +.. note:: + + Elements **must** be appended individually for repeated fields of `struct.Value`. + + .. code-block:: python + + class Row(proto.Message): + values = proto.RepeatedField(proto.MESSAGE, number=1, message=struct.Value,) + + >>> row = Row() + >>> values = [struct_pb2.Value(string_value="hello")] + >>> for v in values: + >>> row.values.append(v) + + Direct assignment will result in an error. + + .. code-block:: python + + class Row(proto.Message): + values = proto.RepeatedField(proto.MESSAGE, number=1, message=struct.Value,) + + >>> row = Row() + >>> row.values = [struct_pb2.Value(string_value="hello")] + Traceback (most recent call last): + File "", line 1, in + File "/usr/local/google/home/busunkim/github/python-automl/.nox/unit-3-8/lib/python3.8/site-packages/proto/message.py", line 543, in __setattr__ + self._pb.MergeFrom(self._meta.pb(**{key: pb_value})) + TypeError: Value must be iterable + + Map fields ---------- @@ -168,3 +198,6 @@ one-variant ``oneof``. See the protocolbuffers documentation_ for more information. .. _documentation: https://github.com/protocolbuffers/protobuf/blob/v3.12.0/docs/field_presence.md + + + diff --git a/docs/reference/datetime_helpers.rst b/docs/reference/datetime_helpers.rst new file mode 100644 index 00000000..e45ad1fe --- /dev/null +++ b/docs/reference/datetime_helpers.rst @@ -0,0 +1,5 @@ +Datetime Helpers +---------------- + +.. automodule:: proto.datetime_helpers + :members: diff --git a/docs/reference/index.rst b/docs/reference/index.rst index 85af2afe..35b01946 100644 --- a/docs/reference/index.rst +++ b/docs/reference/index.rst @@ -4,15 +4,16 @@ Reference Below is a reference for the major classes and functions within this module. -It is split into two main sections: - - The :doc:`message` section (which uses the ``message`` and ``fields`` modules) handles constructing messages. - The :doc:`marshal` module handles translating between internal protocol buffer instances and idiomatic equivalents. +- The :doc:`datetime_helpers` has datetime related helpers to maintain + nanosecond precision. .. toctree:: :maxdepth: 2 message marshal + datetime_helpers diff --git a/docs/reference/message.rst b/docs/reference/message.rst index 1d9e070c..d9752b5d 100644 --- a/docs/reference/message.rst +++ b/docs/reference/message.rst @@ -5,8 +5,11 @@ Message and Field :members: .. automethod:: pb + .. automethod:: wrap .. automethod:: serialize .. automethod:: deserialize + .. automethod:: to_json + .. automethod:: from_json .. automodule:: proto.fields diff --git a/setup.py b/setup.py index 695611a6..cf5df00e 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ from setuptools import find_packages, setup -version = "1.10.1" +version = "1.10.2" PACKAGE_ROOT = os.path.abspath(os.path.dirname(__file__))