text: __all__ = (
      "get_pattern",
      "is_classinfo",
      "has_unique_items",
      "Validator",
  )
  
  import re
  
  from typing import (
      Any,
      AnyStr,
      Iterable,
      Hashable,
      Pattern,
      Callable,
      Optional,
  )
  
  from resultful import (
      Result,
  )
  
  from testplates.impl.exceptions import (
      TestplatesError,
  )
  
  Validator = Callable[[Any], Result[None, TestplatesError]]
  
  
  def get_pattern(
      pattern: Optional[AnyStr],
  ) -> Optional[Pattern[AnyStr]]:
  
      """
      Returns compiled pattern if string pattern is not None, otherwise None.
      """
  
      return re.compile(pattern) if pattern is not None else None
  
  
  def is_classinfo(
      classinfo: type,
      /,
  ) -> bool:
      try:
          isinstance(object, classinfo)
      except TypeError:
          return False
      else:
          return True
  
  
  def has_unique_items(
      items: Iterable[Hashable],
  ) -> bool:
      visited = set()
  
      for item in items:
          if item in visited:
              return False
          else:
              visited.add(item)
  
      return True
  