class_docstr: Parse a requirement.
  
  Parse a given requirement string into its parts, such as name, specifier,
  URL, and extras. Raises InvalidRequirement on a badly-formed requirement
  string.
class_docstr_tok: ["Parse","a","requirement",".","Parse","a","given","requirement","string","into","its","parts",",","such","as","name",",","specifier",",","URL",",","and","extras",".","Raises","InvalidRequirement","on","a","badly-formed","requirement","string","."]
code: def __init__(self, requirement_string: str) -> None:
      try:
          req = REQUIREMENT.parseString(requirement_string)
      except ParseException as e:
          raise InvalidRequirement(
              f'Parse error at "{ requirement_string[e.loc : e.loc + 8]!r}": {e.msg}'
          )
  
      self.name: str = req.name
      if req.url:
          parsed_url = urllib.parse.urlparse(req.url)
          if parsed_url.scheme == "file":
              if urllib.parse.urlunparse(parsed_url) != req.url:
                  raise InvalidRequirement("Invalid URL given")
          elif not (parsed_url.scheme and parsed_url.netloc) or (
              not parsed_url.scheme and not parsed_url.netloc
          ):
              raise InvalidRequirement(f"Invalid URL: {req.url}")
          self.url: TOptional[str] = req.url
      else:
          self.url = None
      self.extras: Set[str] = set(
          req.extras.asList() if req.extras else []
      )
      self.specifier: SpecifierSet = SpecifierSet(req.specifier)
      self.marker: TOptional[Marker] = (
          req.marker if req.marker else None
      )
  
file_path: catboost/contrib/python/packaging/py3/packaging/requirements.py
imports: import re
  import string
  import urllib.parse
  from typing import List, Optional, Set
  from pyparsing import Combine, Literal, Optional, ParseException, Regex, Word, ZeroOrMore, originalTextFor, stringEnd, stringStart
  from .markers import MARKER_EXPR, Marker
  from .specifiers import LegacySpecifier, Specifier, SpecifierSet
label_desc: Use image node_id 1 to create a new Requirement object  with example: obj = Requirement(requirement_string)