class_docstr: Represent colors by specifying their Red, Green, and Blue channels.
  
  Alpha values may also optionally be provided. Otherwise, alpha values
  default to 1.
class_docstr_tok: ["Represent","colors","by","specifying","their","Red",",","Green",",","and","Blue","channels",".","Alpha","values","may","also","optionally","be","provided",".","Otherwise",",","alpha","values","default","to","1","."]
docstr: Create an RGB color from a RGB(A) hex string.
  
  Args:
      hex_string (str) :
          String containing hex-encoded RGBA(A) values. Valid formats
          are '#rrggbb', '#rrggbbaa', '#rgb' and '#rgba'.
  
  Returns:
      :class:`~bokeh.colors.RGB`
docstr_tok: ["Create","an","RGB","color","from","a","RGB","(","A",")","hex","string",".","Args",":","hex_string","(","str",")",":","String","containing","hex-encoded","RGBA","(","A",")","values",".","Valid","formats","are","'","#","rrggbb","'",",","'","#","rrggbbaa","'",",","'","#","rgb","'","and","'","#","rgba","'",".","Returns",":",":","class",":","`","~bokeh.colors.RGB","`"]
code: def from_hex_string(cls, hex_string: str) -> RGB:
      """Create an RGB color from a RGB(A) hex string.
  
      Args:
          hex_string (str) :
              String containing hex-encoded RGBA(A) values. Valid formats
              are '#rrggbb', '#rrggbbaa', '#rgb' and '#rgba'.
  
      Returns:
          :class:`~bokeh.colors.RGB`
  
      """
      if isinstance(hex_string, str):
          # Hex color as #rrggbbaa or #rrggbb
          if match(r"#([\da-fA-F]{2}){3,4}\Z", hex_string):
              r = int(hex_string[1:3], 16)
              g = int(hex_string[3:5], 16)
              b = int(hex_string[5:7], 16)
              a = (
                  int(hex_string[7:9], 16) / 255.0
                  if len(hex_string) > 7
                  else 1.0
              )
              return RGB(r, g, b, a)
  
          # Hex color as #rgb or #rgba
          if match(r"#[\da-fA-F]{3,4}\Z", hex_string):
              r = int(hex_string[1] * 2, 16)
              g = int(hex_string[2] * 2, 16)
              b = int(hex_string[3] * 2, 16)
              a = (
                  int(hex_string[4] * 2, 16) / 255.0
                  if len(hex_string) > 4
                  else 1.0
              )
              return RGB(r, g, b, a)
  
      raise ValueError(
          f"'{hex_string}' is not an RGB(A) hex color string"
      )
  
imports: from __future__ import annotations
  import logging
  import colorsys
  from abc import ABCMeta, abstractmethod
  from math import sqrt
  from re import match
  from typing import TYPE_CHECKING, Union
  from ..core.serialization import AnyRep, Serializable, Serializer
  from ..util.deprecation import deprecated
label_desc: Use image node_id 4 for calling the RGB obj's underlying member method code with example usage: obj.from_hex_string(cls, hex_string) and returns: RGB, RGB