Example #1
0
def _multiple_choice_validator(choices, name, value):
    values = utils._check_csv(value)
    for csv_value in values:
        if csv_value not in choices:
            msg = "option %s: invalid value: %r, should be in %s"
            raise optparse.OptionValueError(msg % (name, csv_value, choices))
    return values
Example #2
0
def _confidence_transformer(value: str) -> Sequence[str]:
    """Transforms a comma separated string of confidence values."""
    values = pylint_utils._check_csv(value)
    for confidence in values:
        if confidence not in interfaces.CONFIDENCE_LEVEL_NAMES:
            raise argparse.ArgumentTypeError(
                f"{value} should be in {*interfaces.CONFIDENCE_LEVEL_NAMES,}")
    return values
Example #3
0
 def __call__(
     self,
     parser: argparse.ArgumentParser,
     namespace: argparse.Namespace,
     values: Union[str, Sequence[Any], None],
     option_string: Optional[str] = "--enable",
 ) -> None:
     assert isinstance(values, (tuple, list))
     msgids = utils._check_csv(values[0])
     try:
         for msgid in msgids:
             self.linter.enable(msgid)
     except exceptions.UnknownMessageError:
         # pylint: disable-next=fixme
         # TODO: Optparse: Raise an informational warning here
         pass
Example #4
0
 def _call(
     self,
     xabling_function: Callable[[str], None],
     values: str | Sequence[Any] | None,
     option_string: str | None,
 ):
     assert isinstance(values, (tuple, list))
     for msgid in utils._check_csv(values[0]):
         try:
             xabling_function(msgid)
         except (
                 exceptions.DeletedMessageError,
                 exceptions.MessageBecameExtensionError,
         ) as e:
             self.linter._stashed_messages[(self.linter.current_name,
                                            "useless-option-value")].append(
                                                (option_string, str(e)))
         except exceptions.UnknownMessageError:
             self.linter._stashed_messages[(self.linter.current_name,
                                            "unknown-option-value")].append(
                                                (option_string, msgid))
Example #5
0
def _csv_validator(_, name, value):
    return utils._check_csv(value)
Example #6
0
def _csv_transformer(value: str) -> Sequence[str]:
    """Transforms a comma separated string."""
    return pylint_utils._check_csv(value)