Age | Commit message (Collapse) | Author |
|
PiperOrigin-RevId: 478521309
Change-Id: Ica34fdda749b928fcf73e030bc3fa4e1585a753c
|
|
PiperOrigin-RevId: 475611494
Change-Id: I9facdfcaece0b3c0bd2b0b38364ecd41cb06d79c
|
|
PiperOrigin-RevId: 474195462
Change-Id: I2b57d8ea6b8eb66d1f777f026fb19e5401983789
|
|
PiperOrigin-RevId: 473306343
Change-Id: I4c166f7fa34ce2f1b0bcacafbf790d4f932886d1
|
|
This also makes sphinx autodoc generate docs for exposed APIs.
Also make `absl.flags`'s docstring compatible with reST.
PiperOrigin-RevId: 469768218
Change-Id: I6fd3807de05d6803a0aa73b3872555e53d504e8d
|
|
to add generated docs by Sphinx/readthedocs.
This is just an initial pass, far from great documentations.
PiperOrigin-RevId: 468721475
Change-Id: I5b4f9b2127add933d7eb56414b4fa1751cdacb3d
|
|
an iterable of concrete enum values are used as the default.
PiperOrigin-RevId: 461656002
Change-Id: Ic6d0699ad4f507d9f6ae24ab4aad0d7b8b19bd63
|
|
PiperOrigin-RevId: 453697925
Change-Id: I24a9fbbe2a690d7101b7190f4b4976d16bd0942f
|
|
Now that we've dropped Python 2 support, we can drop the conditional import of `typing`.
PiperOrigin-RevId: 450471818
Change-Id: I6c4efc7b6943b9794b2a3cf1eba90d330d6b73fd
|
|
PiperOrigin-RevId: 447005334
Change-Id: Iea86a969093640a18663d3d135648329c45e9954
|
|
PiperOrigin-RevId: 446842401
Change-Id: Ic66c537d810dda858318a95e5f7b2242f58f7c75
|
|
Also remove the mock package in bazel WORKSPACE file.
PiperOrigin-RevId: 436585035
Change-Id: I7f8eafac5f7b10dc8f580db20c7ae60711dfdf12
|
|
PiperOrigin-RevId: 436293697
Change-Id: I4ebf90127a781162636fa728c8899d76937dbca6
|
|
PiperOrigin-RevId: 430280700
Change-Id: I62ca45c7b794989f9e8ee66094fb73c5ac7a6840
|
|
bool context (not useful) to avoid situations where someone really wanted to refer to `their_flag.value` instead. This prevents logic bugs.
There were ~10 problems found by this and cleaned up in our internal codebase.
PiperOrigin-RevId: 427295923
Change-Id: Ifc9e086133986cc14d052a06889a93c1ab0ff688
|
|
PiperOrigin-RevId: 423878454
Change-Id: Iadc82651ecd39954cfd2af6b4bae2a98388fd75b
|
|
PiperOrigin-RevId: 423095241
Change-Id: Ie78fb886746b11320e777587bf50c938d9054e37
|
|
these functions are not, not in _validators.py.
PiperOrigin-RevId: 407853170
Change-Id: Iff13f2a1ca391109f9a7e85f2a91abbe3cba3c53
|
|
end-of-life for more than a year now.
PiperOrigin-RevId: 405511743
Change-Id: Id0f78693a6de9474576c3cfa879caf2cc177d8f6
|
|
directory after #159 (#160).
PiperOrigin-RevId: 399810236
Change-Id: Ia78c6e27fbcf65c2c9e0de0d1c171c7a172f450a
|
|
The `FlagHolder` object is returned from `flags.DEFINE_*()` to allow
type-safe and fully-declared access via `myflag.value`, instead of
requiring users to write `FLAGS.myflag`.
Additionally, this proxies the `.default` property from the `Flag`
object underlying the `FlagHolder`, so `FLAGS['myflag'].default` can
instead be written as simply `myflag.default`.
However, the `.present` property is not easily available today without
writing `FLAGS['myflag'].present` or `FLAGS[myflag.name].present`,
despite being relatively commonly used.
Since it intuitively makes sense for this to be available, let's proxy
it through `FlagHolder` to the underlying `Flag` object.
PiperOrigin-RevId: 386901861
Change-Id: I29e3173668080957b796c8634527382b792aa4ec
|
|
This is a required argument for custom argparse.Action classes, and is used when the `ArgumentParse` is created with a `argument_default=`.
PiperOrigin-RevId: 385601086
Change-Id: I01ef4870aa4f0e92f7e8f9be0125c9a0dba16c6f
|
|
PiperOrigin-RevId: 379363540
Change-Id: Ic67abe5de18ad10764007066ea0ecb2bedf1f1da
|
|
PiperOrigin-RevId: 378281281
Change-Id: Id11546b04a8f21ea65b3a22bbd79e348b7217f5e
|
|
missing required flag.
Given these required flags of float values with default value of None:
flags.mark_flags_as_required(["x", "y", "z"])
If none of the required flags are passed as arguments, the resulting error will only show the first missing required flag as an issue:
FATAL Flags parsing error: flag --x=None: Flag --x must have a value other than None.
The user will then add this required flag "x" and try again, but then get the error for "y" as a missing requirement. This loops until the user finally passes all the required flags as arguments.
Since we already know which flags are required, this changes the error message shows all missing required flags at once, so the user can make the necessary changes in a single pass with the error message showing this:
FATAL Flags parsing error:
flag --x=None: Flag --x must have a value other than None.
flag --y=None: Flag --y must have a value other than None.
flag --z=None: Flag --z must have a value other than None.
To achieve the formatting change, `app.parse_flags_with_usage` now puts the error message on a new line and adds indentation if the message is multi-line string.
PiperOrigin-RevId: 371414012
Change-Id: Id7456e9c293fb95d7b4551fd28441610af9b3030
|
|
PiperOrigin-RevId: 369277659
Change-Id: I2f77b2b73abebd3cfc6558e0e8088623702d1d5a
|
|
PiperOrigin-RevId: 368897376
Change-Id: Ie4797bf9c2323c985e506dea0238f2d632508111
|
|
PiperOrigin-RevId: 365814855
Change-Id: Idd59a6052f36b1e6b54f998094e58866242f54ea
|
|
They are considered as public flags and callers should use them instead of accessing FLAGS.test_tmpdir and FLAGS.test_srcdir.
PiperOrigin-RevId: 360948844
Change-Id: Ib3673ae55ad9b55000fb80ba60647a93fdfc0426
|
|
This is to (formally) allow using it in extension libraries.
Also add a test to cover non-comma separators.
PiperOrigin-RevId: 359820150
Change-Id: I3a384083a1634d1429b6a01b10571ebfb7ee9ac1
|
|
PiperOrigin-RevId: 357245847
Change-Id: I7637199f61f23e78646720ad406f539c89962fe3
|
|
PiperOrigin-RevId: 356499864
Change-Id: I729590e449d14420622b6aaae08b13894ce973d6
|
|
PiperOrigin-RevId: 356337920
Change-Id: I6bcef41b5137945a1977148bafd622dc0be59cda
|
|
first `@overload` is to only match when `required=` is passed True.
Previously, omitting `required=` (all most all the calls) matches it, resulting in `_FLAG.value` being non-optional when `default=None`.
PiperOrigin-RevId: 354557367
Change-Id: I05e8b705ed0b02189f6d5e09bef4095b87499cad
|
|
PiperOrigin-RevId: 352859771
Change-Id: Id087eeec5837d76935d05d3596048c8f2ee0f124
|
|
PiperOrigin-RevId: 352689567
Change-Id: Ic0b50423f238ae9b685822a8eecc1ef0997db59d
|
|
there.
PiperOrigin-RevId: 350446790
Change-Id: Iafcb21051f8c3cedf96524fa02ad38a36ff548b2
|
|
Setting it to true, is functionally equivalent to calling `flags.mark_flag_as_required(flag_name)`, but changes the type of returned flagholder.
```
_A : FlagHolder[Optional[str]] = flags.DEFINE_string(
name='a', default=None, help='help')
flags.mark_flag_as_required('a')
```
v/s
```
_A : FlagHolder[str] = flags.DEFINE_string(
name='a', default=None, help='help', required=True)
```
PiperOrigin-RevId: 348825600
Change-Id: Ia7610af1b5c4649c20aba5cbb620eae1359ad592
|
|
PiperOrigin-RevId: 347713086
Change-Id: Ib5c2a08b76a78c75b5db4d72e04049d5446e1c55
|
|
sub-directories.
PiperOrigin-RevId: 345268951
Change-Id: I26871ecb3ad35b9a74ca5668dd9b2c74ddb77c15
|
|
PiperOrigin-RevId: 343548107
Change-Id: I0dbd95804ce720b9ff3cd82bb821bd9e5f26b83c
|
|
PiperOrigin-RevId: 343411193
Change-Id: I7f934a0841a37bb561d5237ac32ed525e05cb696
|
|
PiperOrigin-RevId: 343384654
Change-Id: I6da1be2d0208fdbe7bcdb3bc1e1b06d666e429a2
|
|
With the aim of steering users away from potential pitfalls in usage of the `FlagHolder` API, this change introduces implementation overrides for the class `__eq__` and `__bool__` methods which turn any such usage into a `TypeError` at runtime.
This is to help avoid situations where a user neglects to use the `FlagHolder.value` property in cases where they intended to, e.g.,
```
>>> SOME_FLAG = flags.DEFINE_boolean(...)
>>> if SOME_FLAG: do_something()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: bool() not supported for instances of type 'FlagHolder' (did you mean to use 'FlagHolder.value' instead?)
```
PiperOrigin-RevId: 338473759
Change-Id: If3b6505a3bdca03db6d96ec7cc28e7214cb1a5e7
|
|
This resolves an issue where multi-flag validators rely on specific flag combinations.
PiperOrigin-RevId: 334625442
Change-Id: I7e6b625637a70356df57a4d9cbb01c203f14df4c
|
|
do not encourage dual use of modules as both directly executable and importable.
PiperOrigin-RevId: 328193869
Change-Id: I4fa1d43c6e226b1239bd8bc66900c99cf5ce6abe
|
|
This is to bridge the gap between lower case being idiomatic for command
line values, and upper case for values defined in an `Enum`. It also makes
it more consistent with `DEFINE_enum` usage, which usually uses lower case values.
Case sensitivity can be restored by passing `case_sensitive=True`.
When `case_sensitive=False` (the default), the associated flag serializers will lowercase enum member names. This seemed reasonable since help text that SCREAMS at you is inconsistent with the fact that member names will be provided most often in lowercase format.
Internally, EnumParser is re-used for simplicity.
PiperOrigin-RevId: 324594299
Change-Id: I2e15448ad00a095212756c5277b08219a9e84d55
|
|
PiperOrigin-RevId: 317893235
Change-Id: I7b9ccd1fc92a1313efcba0528018bd47327e0585
|
|
(a) For a flag with default None, define_* will return a FlagHolder[Optional[T]]
(b) For a flag with default != None, define_* will return a FlagHolder[T]
When we are unable to express "default != None", we always return FlagHolder[Optional[T]]
This assumes that the type of default() and value() will be the same.
This assumption holds, till we want the type system to understand that a "required" flag with a None default cannot return a None value.
Changes:
- When exact types for default is known, add @overloads for the DEFINE_* methods for the None case and remaining cases.
- When exact types for default is now known, change return type to FlagHolder[Optional[T]] -- which has same semantics of what FlagHolder[T] used to have.
PiperOrigin-RevId: 315519341
Change-Id: I88dc63b3c5271e12f3274b7246eb602b91b84caf
|
|
PiperOrigin-RevId: 313600007
Change-Id: I7a095f2f2dd334e8be777c558a1075cc181d7b69
|