code: def _build_codes() -> Dict[str, Dict[str, str]]:
      
      built = {
          'fore': {},
          'back': {},
          'style': {},
      }  # type: Dict[str, Dict[str, str]]
  
      # Set codes for forecolors (30-37) and backcolors (40-47)
      # Names are given to some of the 256-color variants as 'light' colors.
      for name, number in _namemap:
          # Not using format_* functions here, no validation needed.
          built['fore'][name] = codeformat(30 + number)
          built['back'][name] = codeformat(40 + number)
          litename = 'light{}'.format(name)  # type: str
          built['fore'][litename] = codeformat(90 + number)
          built['back'][litename] = codeformat(100 + number)
  
      # Set reset codes for fore/back.
      built['fore']['reset'] = codeformat(39)
      built['back']['reset'] = codeformat(49)
  
      # Set style codes.
      for code, names in _stylemap:
          for alias in names:
              built['style'][alias] = codeformat(code)
  
      # Extended (256 color codes)
      for i in range(256):
          built['fore'][str(i)] = extforeformat(i)
          built['back'][str(i)] = extbackformat(i)
  
      return built
docs: Build code map, encapsulated to reduce module-level globals.