Skip to content

PyGlove v0.4.5

Latest

Choose a tag to compare

@daiyip daiyip released this 15 Jul 19:08
· 32 commits to main since this release

This stable-version release includes major updates and enhancements/bug fixes since Jan 2024.

Major updates

  • Python 3.13 support (d655ea0)

  • Introduce pg.views module: PyGlove's view sub-system for rendering objects. (b7e1e83)

  • Introduce pg.coding module: Utilities for code generation. (a4e5373)

    • Source code evaluation with permission control. (23ca0c2)

Enhancements

  • New features

    • pg.Dict to support int keys. (120e8bd)
    • Add pg.ContextualObject for contextual attribute retrieval. (ba91fc7)
  • Object typing

    • Support JSON schema conversion through pg.typing.ValueSpec.to_json_schema. (9018f25)
    • Support __future__.annotations. (97d6446, 65c7e52)
    • Support Protocol subclasses. (50d8a38)
    • Support ClassVar, Final and pg.Ref[Type] annotations. (005ec58)
    • Allow override abstract property through symbolic attribute. (f7390c1)
    • Enum fields could extend int/str fields. (aac846b)
    • pg.typing.Union preserves the order of candidates. (590584d)
    • Enables auto_typing for pg.patcher. (7b56371)
    • Frozen fields will be absent from init signature. (e6810a8)
    • Better forward reference handling. (a040480)
  • Object serialization

    • Add pg.open_jsonl and pg.io.open_sequence API for serializing/deserializing sequence data. (825db90)
    • Add pg.JSONConvertible.load_types_for_deserialization to allow type override during deserialization. (a600470)
    • Allow pg.Ref to be serialized. (016992e)
    • pg.from_json to support auto_import argument. (c8431bf)
    • pg.to_json to support force_dict argument. (328c956)
  • Object formatting

    • pg.format to support recursive structures. (29591ea)
    • pg.Formattable.__str_kwargs__ and __repr_kwargs__ to control default format arguments. (d5dd3c6)
    • Frozen fields will not be present during formatting. (e6810a8)
    • pg.Object.format to control str/bytes field length via max_str_len and max_bytes_len. ((5b9fba4)[https://github.com/google/pyglove/commit/5b9fba467e9f582e6110dce74a08cfc510290206])
    • pg.format to support custom_format argument. (a78a78e)
    • pg.Formattable to control whether to apply markdown quotes. (c97818d)
  • Object reference

    • Add pg.deref to dereference a symbolic tree. ((120e924)[https://github.com/google/pyglove/commit/120e924aaad461b766aff0bf65702c3c1fd9776e])
  • Object mutations

    • pg.evolve to support mutations on root element. (cc456b1)
  • Utilities

    • Add pg.colored and pg.decolor for ANSI text color. (1125d6d)
    • Add pg.ErrorInfo to serialize errors. (2800792)
    • Add pg.timeit context manager. (b1571e1)
    • pg.catch_errors to include error class name for regex matching. (2e40414)
    • Add pg.logging.register_frame_to_skip to better support wrappers. (9c0086a)

Bug fixes

  • Fix serialization of pg.Object with child dict of non-standard keys. (0adebc9)
  • pg.Object: Inherit symbolic attributes from base even when it's overridden as properties. (aad25de)
  • pg.typing.ForwardRef no longer cache resolved class, which allows module reloading. (a92e69e)

API changes

  • Rename pg.Object.schema to pg.Object.type_name. (feb3d56)
  • Rename pg.object_utils to pg.utils (old name is preserved as alias). (f3f06ae)