• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Python Absl Changelog
2
3All notable changes to Python Absl are recorded here.
4
5The format is based on [Keep a Changelog](https://keepachangelog.com).
6
7## Unreleased
8
9Nothing notable unreleased.
10
11## 1.4.0 (2023-01-11)
12
13### New
14
15*   (testing) Added `@flagsaver.as_parsed`: this allows saving/restoring flags
16    using string values as if parsed from the command line and will also reflect
17    other flag states after command line parsing, e.g. `.present` is set.
18
19### Changed
20
21*   (logging) If no log dir is specified `logging.find_log_dir()` now falls back
22    to `tempfile.gettempdir()` instead of `/tmp/`.
23
24### Fixed
25
26*   (flags) Additional kwargs (e.g. `short_name=`) to `DEFINE_multi_enum_class`
27    are now correctly passed to the underlying `Flag` object.
28
29## 1.3.0 (2022-10-11)
30
31### Added
32
33*   (flags) Added a new `absl.flags.set_default` function that updates the flag
34    default for a provided `FlagHolder`. This parallels the
35    `absl.flags.FlagValues.set_default` interface which takes a flag name.
36*   (flags) The following functions now also accept `FlagHolder` instance(s) in
37    addition to flag name(s) as their first positional argument:
38    -   `flags.register_validator`
39    -   `flags.validator`
40    -   `flags.register_multi_flags_validator`
41    -   `flags.multi_flags_validator`
42    -   `flags.mark_flag_as_required`
43    -   `flags.mark_flags_as_required`
44    -   `flags.mark_flags_as_mutual_exclusive`
45    -   `flags.mark_bool_flags_as_mutual_exclusive`
46    -   `flags.declare_key_flag`
47
48### Changed
49
50*   (testing) Assertions `assertRaisesWithPredicateMatch` and
51    `assertRaisesWithLiteralMatch` now capture the raised `Exception` for
52    further analysis when used as a context manager.
53*   (testing) TextAndXMLTestRunner now produces time duration values with
54    millisecond precision in XML test result output.
55*   (flags) Keyword access to `flag_name` arguments in the following functions
56    is deprecated. This parameter will be renamed in a future 2.0.0 release.
57    -   `flags.register_validator`
58    -   `flags.validator`
59    -   `flags.register_multi_flags_validator`
60    -   `flags.multi_flags_validator`
61    -   `flags.mark_flag_as_required`
62    -   `flags.mark_flags_as_required`
63    -   `flags.mark_flags_as_mutual_exclusive`
64    -   `flags.mark_bool_flags_as_mutual_exclusive`
65    -   `flags.declare_key_flag`
66
67## 1.2.0 (2022-07-18)
68
69### Fixed
70
71*   Fixed a crash in Python 3.11 when `TempFileCleanup.SUCCESS` is used.
72
73## 1.1.0 (2022-06-01)
74
75*   `Flag` instances now raise an error if used in a bool context. This prevents
76    the occasional mistake of testing an instance for truthiness rather than
77    testing `flag.value`.
78*   `absl-py` no longer depends on `six`.
79
80## 1.0.0 (2021-11-09)
81
82### Changed
83
84*   `absl-py` no longer supports Python 2.7, 3.4, 3.5. All versions have reached
85    end-of-life for more than a year now.
86*   New releases will be tagged as `vX.Y.Z` instead of `pypi-vX.Y.Z` in the git
87    repo going forward.
88
89## 0.15.0 (2021-10-19)
90
91### Changed
92
93*   (testing) #128: When running bazel with its `--test_filter=` flag, it now
94    treats the filters as `unittest`'s `-k` flag in Python 3.7+.
95
96## 0.14.1 (2021-09-30)
97
98### Fixed
99
100*   Top-level `LICENSE` file is now exported in bazel.
101
102## 0.14.0 (2021-09-21)
103
104### Fixed
105
106*   #171: Creating `argparse_flags.ArgumentParser` with `argument_default=` no
107    longer raises an exception when other `absl.flags` flags are defined.
108*   #173: `absltest` now correctly sets up test filtering and fail fast flags
109    when an explicit `argv=` parameter is passed to `absltest.main`.
110
111## 0.13.0 (2021-06-14)
112
113### Added
114
115*   (app) Type annotations for public `app` interfaces.
116*   (testing) Added new decorator `@absltest.skipThisClass` to indicate a class
117    contains shared functionality to be used as a base class for other
118    TestCases, and therefore should be skipped.
119
120### Changed
121
122*   (app) Annotated the `flag_parser` paramteter of `run` as keyword-only. This
123    keyword-only constraint will be enforced at runtime in a future release.
124*   (app, flags) Flag validations now include all errors from disjoint flag
125    sets, instead of fail fast upon first error from all validators. Multiple
126    validators on the same flag still fails fast.
127
128## 0.12.0 (2021-03-08)
129
130### Added
131
132*   (flags) Made `EnumClassSerializer` and `EnumClassListSerializer` public.
133*   (flags) Added a `required: Optional[bool] = False` parameter to `DEFINE_*`
134    functions.
135*   (testing) flagsaver overrides can now be specified in terms of FlagHolder.
136*   (testing) `parameterized.product`: Allows testing a method over cartesian
137    product of parameters values, specified as a sequences of values for each
138    parameter or as kwargs-like dicts of parameter values.
139*   (testing) Added public flag holders for `--test_srcdir` and `--test_tmpdir`.
140    Users should use `absltest.TEST_SRCDIR.value` and
141    `absltest.TEST_TMPDIR.value` instead of `FLAGS.test_srcdir` and
142    `FLAGS.test_tmpdir`.
143
144### Fixed
145
146*   (flags) Made `CsvListSerializer` respect its delimiter argument.
147
148## 0.11.0 (2020-10-27)
149
150### Changed
151
152*   (testing) Surplus entries in AssertionError stack traces from absltest are
153    now suppressed and no longer reported in the xml_reporter.
154*   (logging) An exception is now raised instead of `logging.fatal` when logging
155    directories cannot be found.
156*   (testing) Multiple flags are now set together before their validators run.
157    This resolves an issue where multi-flag validators rely on specific flag
158    combinations.
159*   (flags) As a deterrent for misuse, FlagHolder objects will now raise a
160    TypeError exception when used in a conditional statement or equality
161    expression.
162
163## 0.10.0 (2020-08-19)
164
165### Added
166
167*   (testing) `_TempDir` and `_TempFile` now implement `__fspath__` to satisfy
168    `os.PathLike`
169*   (logging) `--logger_levels`: allows specifying the log levels of loggers.
170*   (flags) `FLAGS.validate_all_flags`: a new method that validates all flags
171    and raises an exception if one fails.
172*   (flags) `FLAGS.get_flags_for_module`: Allows fetching the flags a module
173    defines.
174*   (testing) `parameterized.TestCase`: Supports async test definitions.
175*   (testing,app) Added `--pdb` flag: When true, uncaught exceptions will be
176    handled by `pdb.post_mortem`. This is an alias for `--pdb_post_mortem`.
177
178### Changed
179
180*   (testing) Failed tests output a copy/pastable test id to make it easier to
181    copy the failing test to the command line.
182*   (testing) `@parameterized.parameters` now treats a single `abc.Mapping` as a
183    single test case, consistent with `named_parameters`. Previously the
184    `abc.Mapping` is treated as if only its keys are passed as a list of test
185    cases. If you were relying on the old inconsistent behavior, explicitly
186    convert the `abc.Mapping` to a `list`.
187*   (flags) `DEFINE_enum_class` and `DEFINE_mutlti_enum_class` accept a
188    `case_sensitive` argument. When `False` (the default), strings are mapped to
189    enum member names without case sensitivity, and member names are serialized
190    in lowercase form. Flag definitions for enums whose members include
191    duplicates when case is ignored must now explicitly pass
192    `case_sensitive=True`.
193
194### Fixed
195
196*   (flags) Defining an alias no longer marks the aliased flag as always present
197    on the command line.
198*   (flags) Aliasing a multi flag no longer causes the default value to be
199    appended to.
200*   (flags) Alias default values now matched the aliased default value.
201*   (flags) Alias `present` counter now correctly reflects command line usage.
202
203## 0.9.0 (2019-12-17)
204
205### Added
206
207*   (testing) `TestCase.enter_context`: Allows using context managers in setUp
208    and having them automatically exited when a test finishes.
209
210### Fixed
211
212*   #126: calling `logging.debug(msg, stack_info=...)` no longer throws an
213    exception in Python 3.8.
214
215## 0.8.1 (2019-10-08)
216
217### Fixed
218
219*   (testing) `absl.testing`'s pretty print reporter no longer buffers
220    RUN/OK/FAILED messages.
221*   (testing) `create_tempfile` will overwrite pre-existing read-only files.
222
223## 0.8.0 (2019-08-26)
224
225### Added
226
227*   (testing) `absltest.expectedFailureIf`: a variant of
228    `unittest.expectedFailure` that allows a condition to be given.
229
230### Changed
231
232*   (bazel) Tests now pass when bazel
233    `--incompatible_allow_python_version_transitions=true` is set.
234*   (bazel) Both Python 2 and Python 3 versions of tests are now created. To
235    only run one major Python version, use `bazel test
236    --test_tag_filters=-python[23]` to ignore the other version.
237*   (testing) `assertTotallyOrdered` no longer requires objects to implement
238    `__hash__`.
239*   (testing) `absltest` now integrates better with `--pdb_post_mortem`.
240*   (testing) `xml_reporter` now includes timestamps to testcases, test_suite,
241    test_suites elements.
242
243### Fixed
244
245*   #99: `absl.logging` no longer registers itself to `logging.root` at import
246    time.
247*   #108: Tests now pass with Bazel 0.28.0 on macOS.
248
249## 0.7.1 (2019-03-12)
250
251### Added
252
253*   (flags) `flags.mark_bool_flags_as_mutual_exclusive`: convenience function to
254    check that only one, or at most one, flag among a set of boolean flags are
255    True.
256
257### Changed
258
259*   (bazel) Bazel 0.23+ or 0.22+ is now required for building/testing.
260    Specifically, a Bazel version that supports
261    `@bazel_tools//tools/python:python_version` for selecting the Python
262    version.
263
264### Fixed
265
266*   #94: LICENSE files are now included in sdist.
267*   #93: Change log added.
268
269## 0.7.0 (2019-01-11)
270
271### Added
272
273*   (bazel) testonly=1 has been removed from the testing libraries, which allows
274    their use outside of testing contexts.
275*   (flags) Multi-flags now accept any Iterable type for the default value
276    instead of only lists. Strings are still special cased as before. This
277    allows sets, generators, views, etc to be used naturally.
278*   (flags) DEFINE_multi_enum_class: a multi flag variant of enum_class.
279*   (testing) Most of absltest is now type-annotated.
280*   (testing) Made AbslTest.assertRegex available under Python 2. This allows
281    Python 2 code to write more natural Python 3 compatible code. (Note: this
282    was actually released in 0.6.1, but unannounced)
283*   (logging) logging.vlog_is_on: helper to tell if a vlog() call will actually
284    log anything. This allows avoiding computing expansive inputs to a logging
285    call when logging isn't enabled for that level.
286
287### Fixed
288
289*   (flags) Pickling flags now raises an clear error instead of a cryptic one.
290    Pickling flags isn't supported; instead use flags_into_string to serialize
291    flags.
292*   (flags) Flags serialization works better: the resulting serialized value,
293    when deserialized, won't cause --help to be invoked, thus ending the
294    process.
295*   (flags) Several flag fixes to make them behave more like the Absl C++ flags:
296    empty --flagfile is allowed; --nohelp and --help=false don't display help
297*   (flags) An empty --flagfile value (e.g. "--flagfile=" or "--flagfile=''"
298    doesn't raise an error; its not just ignored. This matches Abseil C++
299    behavior.
300*   (bazel) Building with Bazel 0.2.0 works without extra incompatibility
301    disable build flags.
302
303### Changed
304
305*   (flags) Flag serialization is now deterministic: this improves Bazel build
306    caching for tools that are affected by flag serialization.
307
308## 0.6.0 (2018-10-22)
309
310### Added
311
312*   Tempfile management APIs for tests: read/write/manage tempfiles for test
313    purposes easily and correctly. See TestCase.create_temp{file/dir} and the
314    corresponding commit for more info.
315
316## 0.5.0 (2018-09-17)
317
318### Added
319
320*   Flags enum support: flags.DEFINE_enum_class allows using an `Enum` derived
321    class to define the allowed values for a flag.
322
323## 0.4.1 (2018-08-28)
324
325### Fixed
326
327*   Flags no long allow spaces in their names
328
329### Changed
330
331*   XML test output is written at the end of all test execution.
332*   If the current user's username can't be gotten, fallback to uid, else fall
333    back to a generic 'unknown' string.
334
335## 0.4.0 (2018-08-14)
336
337### Added
338
339*   argparse integration: absl-registered flags can now be accessed via argparse
340    using absl.flags.argparse_flags: see that module for more information.
341*   TestCase.assertSameStructure now allows mixed set types.
342
343### Changed
344
345*   Test output now includes start/end markers for each test ran. This is to
346    help distinguish output from tests clearly.
347
348## 0.3.0 (2018-07-25)
349
350### Added
351
352*   `app.call_after_init`: Register functions to be called after app.run() is
353    called. Useful for program-wide initialization that library code may need.
354*   `logging.log_every_n_seconds`: like log_every_n, but based on elapsed time
355    between logging calls.
356*   `absltest.mock`: alias to unittest.mock (PY3) for better unittest drop-in
357    replacement. For PY2, it will be available if mock is importable.
358
359### Fixed
360
361*   `ABSLLogger.findCaller()`: allow stack_info arg and return value for PY2
362*   Make stopTest locking reentrant: this prevents deadlocks for test frameworks
363    that customize unittest.TextTestResult.stopTest.
364*   Make --helpfull work with unicode flag help strings.
365