def METHOD_NAME(self, requirement: str) -> DependencySpec:
    requirement = requirement.strip()
    specification = self._parse_pep508(requirement)
    if specification is not None:
        return specification
    extras = []
    extras_m = re.search(r"\[([\w\d,-_ ]+)\]$", requirement)
    if extras_m:
        extras = [e.strip() for e in extras_m.group(1).split(",")]
        requirement, _ = requirement.split("[")
    specification = (
        self._parse_url(requirement)
        or self._parse_path(requirement)
        or self._parse_simple(requirement)
    )
    if specification:
        if extras and "extras" not in specification:
            specification["extras"] = extras
        return specification
    raise ValueError(f"Invalid dependency specification: {requirement}")