(self)
| 357 | debug("Context inverse_flags: {!r}".format(self.context.inverse_flags)) |
| 358 | |
| 359 | def complete_flag(self) -> None: |
| 360 | if self.flag: |
| 361 | msg = "Completing current flag {} before moving on" |
| 362 | debug(msg.format(self.flag)) |
| 363 | # Barf if we needed a value and didn't get one |
| 364 | if ( |
| 365 | self.flag |
| 366 | and self.flag.takes_value |
| 367 | and self.flag.raw_value is None |
| 368 | and not self.flag.optional |
| 369 | ): |
| 370 | err = "Flag {!r} needed value and was not given one!" |
| 371 | self.error(err.format(self.flag)) |
| 372 | # Handle optional-value flags; at this point they were not given an |
| 373 | # explicit value, but they were seen, ergo they should get treated like |
| 374 | # bools. |
| 375 | if self.flag and self.flag.raw_value is None and self.flag.optional: |
| 376 | msg = "Saw optional flag {!r} go by w/ no value; setting to True" |
| 377 | debug(msg.format(self.flag.name)) |
| 378 | # Skip casting so the bool gets preserved |
| 379 | self.flag.set_value(True, cast=False) |
| 380 | |
| 381 | def check_ambiguity(self, value: Any) -> bool: |
| 382 | """ |
no test coverage detected