class_docstr: The option parser is an internal class that is ultimately used to
  parse options and arguments.  It's modelled after optparse and brings
  a similar but vastly simplified API.  It should generally not be used
  directly as the high level Click classes wrap it for you.
  
  It's not nearly as extensible as optparse or argparse as it does not
  implement features that are implemented on a higher level (such as
  types or defaults).
  
  :param ctx: optionally the :class:`~click.Context` where this parser
              should go with.
code: def _get_value_from_state(
      self, option_name: str, option: Option, state: ParsingState
  ) -> t.Any:
      nargs = option.nargs
  
      if len(state.rargs) < nargs:
          if option.obj._flag_needs_value:
              # Option allows omitting the value.
              value = _flag_needs_value
          else:
              raise BadOptionUsage(
                  option_name,
                  ngettext(
                      "Option {name!r} requires an argument.",
                      "Option {name!r} requires {nargs} arguments.",
                      nargs,
                  ).format(name=option_name, nargs=nargs),
              )
      elif nargs == 1:
          next_rarg = state.rargs[0]
  
          if (
              option.obj._flag_needs_value
              and isinstance(next_rarg, str)
              and next_rarg[:1] in self._opt_prefixes
              and len(next_rarg) > 1
          ):
              # The next arg looks like the start of an option, don't
              # use it as the value if omitting the value is allowed.
              value = _flag_needs_value
          else:
              value = state.rargs.pop(0)
      else:
          value = tuple(state.rargs[:nargs])
          del state.rargs[:nargs]
  
      return value
  
imports: import typing
  from collections import deque
  from gettext import gettext
  from gettext import ngettext
  from .exceptions import BadArgumentUsage
  from .exceptions import BadOptionUsage
  from .exceptions import NoSuchOption
  from .exceptions import UsageError
label_desc: Use image node_id 9 for calling the OptionParser obj's underlying member method code with example usage: obj._get_value_from_state(option_name, option, state) and returns: value