class_docstr: The :class:`RegexPattern` class is an implementation of a pattern using
  regular expressions.
class_docstr_tok: ["The",":","class",":","`","RegexPattern","`","class","is","an","implementation","of","a","pattern","using","regular","expressions","."]
docstr: Initializes the :class:`RegexPattern` instance.
  
  *pattern* (:class:`str`, :class:`bytes`, :class:`re.Pattern`, or
  :data:`None`) is the pattern to compile into a regular expression.
  
  *include* (:class:`bool` or :data:`None`) must be :data:`None` unless
  *pattern* is a precompiled regular expression (:class:`re.Pattern`) in which
  case it is whether matched files should be included (:data:`True`), excluded
  (:data:`False`), or is a null operation (:data:`None`).
  
          .. NOTE:: Subclasses do not need to support the *include* parameter.
docstr_tok: ["Initializes","the",":","class",":","`","RegexPattern","`","instance",".","*","pattern","*","(",":","class",":","`","str","`",",",":","class",":","`","bytes","`",",",":","class",":","`","re.Pattern","`",",","or",":","data",":","`","None","`",")","is","the","pattern","to","compile","into","a","regular","expression",".","*","include","*","(",":","class",":","`","bool","`","or",":","data",":","`","None","`",")","must","be",":","data",":","`","None","`","unless","*","pattern","*","is","a","precompiled","regular","expression","(",":","class",":","`","re.Pattern","`",")","in","which","case","it","is","whether","matched","files","should","be","included","(",":","data",":","`","True","`",")",",","excluded","(",":","data",":","`","False","`",")",",","or","is","a","null","operation","(",":","data",":","`","None","`",")",".","..","NOTE",":",":","Subclasses","do","not","need","to","support","the","*","include","*","parameter","."]
code: def __init__(
      self,
      pattern: Union[AnyStr, PatternHint, None],
      include: Optional[bool] = None,
  ) -> None:
      """
      Initializes the :class:`RegexPattern` instance.
  
      *pattern* (:class:`str`, :class:`bytes`, :class:`re.Pattern`, or
      :data:`None`) is the pattern to compile into a regular expression.
  
      *include* (:class:`bool` or :data:`None`) must be :data:`None` unless
      *pattern* is a precompiled regular expression (:class:`re.Pattern`) in which
      case it is whether matched files should be included (:data:`True`), excluded
      (:data:`False`), or is a null operation (:data:`None`).
  
              .. NOTE:: Subclasses do not need to support the *include* parameter.
      """
  
      if isinstance(pattern, (str, bytes)):
          assert (
              include is None
          ), f"include:{include!r} must be null when pattern:{pattern!r} is a string."
          regex, include = self.pattern_to_regex(pattern)
          # NOTE: Make sure to allow a null regular expression to be
          # returned for a null-operation.
          if include is not None:
              regex = re.compile(regex)
  
      elif pattern is not None and hasattr(pattern, "match"):
          # Assume pattern is a precompiled regular expression.
          # - NOTE: Used specified *include*.
          regex = pattern
  
      elif pattern is None:
          # NOTE: Make sure to allow a null pattern to be passed for a
          # null-operation.
          assert (
              include is None
          ), f"include:{include!r} must be null when pattern:{pattern!r} is null."
  
      else:
          raise TypeError(
              f"pattern:{pattern!r} is not a string, re.Pattern, or None."
          )
  
      super(RegexPattern, self).__init__(include)
  
      self.pattern: Union[AnyStr, PatternHint, None] = pattern
      """
  		*pattern* (:class:`str`, :class:`bytes`, :class:`re.Pattern`, or
  		:data:`None`) is the uncompiled, input pattern. This is for reference.
  		"""
  
      self.regex: PatternHint = regex
      """
  		*regex* (:class:`re.Pattern`) is the regular expression for the pattern.
  		"""
  
file_path: catboost/contrib/python/pathspec/pathspec/pattern.py
imports: import dataclasses
  import re
  import warnings
  from typing import Any, AnyStr, Iterable, Iterator, Match, Optional, Pattern, Tuple, Union
label_desc: Use image node_id 1 to create a new RegexPattern object from inherited base classes: Pattern with example: obj = RegexPattern(pattern, include)