abseil-py
v2.1.0
published 10 months ago
2,300 stars
246 forks
74 watchers
Apache License 2.0
public
0 assets
Compatability level 1
ij0IMOTrT2bE+pB8Bu32zhxxnO2BGhLibZ0xYvhHF1g=
v2.1.0
January 16, 2024

Added

  • (flags) Added absl.flags.override_value function to provide FlagHolder with a construct to modify values. The new interface parallels absl.flags.FlagValues.__setattr__ but checks that the provided value conforms to the flag's expected type.
  • (testing) Added a new method absltest.TestCase.assertDataclassEqual that tests equality of dataclass.dataclass objects with better error messages when the assert fails.

Changed

  • (flags) absl.flags.argparse_flags.ArgumentParser now correctly inherits an empty instance of FlagValues to ensure that absl flags, such as --flagfile, --undefok are supported.
  • (testing) Do not exit 5 if tests were skipped on Python 3.12. This follows the CPython change in https://github.com/python/cpython/pull/113856.

Fixed

  • (flags) The flag foo no longer retains the value bar after FLAGS.foo = bar fails due to a validation error.
  • (testing) Fixed an issue caused by this Python 3.12.1 change where the test reporter crashes when all tests are skipped.
Deps:

Abseil Python Common Libraries

This repository is a collection of Python library code for building Python applications. The code is collected from Google's own Python code base, and has been extensively tested and used in production.

Features

  • Simple application startup
  • Distributed commandline flags system
  • Custom logging module with additional features
  • Testing utilities

Getting Started

Installation

To install the package, simply run:

pip install absl-py

Or install from source:

python setup.py install

Running Tests

To run Abseil tests, you can clone the git repo and run bazel:

git clone https://github.com/abseil/abseil-py.git
cd abseil-py
bazel test absl/...

Please also validate the type annotations against the latest mypy:

pip install mypy
mypy absl

Example Code

Please refer to smoke_tests/sample_app.py as an example to get started.

Documentation

See the Abseil Python Developer Guide.

Future Releases

The current repository includes an initial set of libraries for early adoption. More components and interoperability with Abseil C++ Common Libraries will come in future releases.

License

The Abseil Python library is licensed under the terms of the Apache license. See LICENSE for more information.