Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
assert result == SpecifierSet(expected)
assert result.prereleases
result = SpecifierSet(left, prereleases=False) & SpecifierSet(right)
assert result == SpecifierSet(expected)
assert not result.prereleases
result = SpecifierSet(left) & SpecifierSet(right, prereleases=True)
assert result == SpecifierSet(expected)
assert result.prereleases
result = SpecifierSet(left) & SpecifierSet(right, prereleases=False)
assert result == SpecifierSet(expected)
assert not result.prereleases
result = SpecifierSet(left, prereleases=True) & SpecifierSet(
right, prereleases=True
)
assert result == SpecifierSet(expected)
assert result.prereleases
result = SpecifierSet(left, prereleases=False) & SpecifierSet(
right, prereleases=False
)
assert result == SpecifierSet(expected)
assert not result.prereleases
with pytest.raises(ValueError):
result = SpecifierSet(left, prereleases=True) & SpecifierSet(
right, prereleases=False
)
def __init__(self, project_name, specs, extras):
"""DO NOT CALL THIS UNDOCUMENTED METHOD; use Requirement.parse()!"""
self.unsafe_name, project_name = project_name, safe_name(project_name)
self.project_name, self.key = project_name, project_name.lower()
self.specifier = packaging.specifiers.SpecifierSet(
",".join(["".join([x, y]) for x, y in specs])
)
self.specs = specs
self.extras = tuple(map(safe_extra, extras))
self.hashCmp = (
self.key,
self.specifier,
frozenset(self.extras),
)
self.__hash = hash(self.hashCmp)
def test_specifiers_combine(self, left, right, expected):
result = SpecifierSet(left) & SpecifierSet(right)
assert result == SpecifierSet(expected)
result = SpecifierSet(left) & right
assert result == SpecifierSet(expected)
result = SpecifierSet(left, prereleases=True) & SpecifierSet(right)
assert result == SpecifierSet(expected)
assert result.prereleases
result = SpecifierSet(left, prereleases=False) & SpecifierSet(right)
assert result == SpecifierSet(expected)
assert not result.prereleases
result = SpecifierSet(left) & SpecifierSet(right, prereleases=True)
assert result == SpecifierSet(expected)
assert result.prereleases
def test_comparison_canonicalizes(self, left, right):
assert SpecifierSet(left) == SpecifierSet(right)
assert left == SpecifierSet(right)
assert SpecifierSet(left) == right
def _validate_pep440_specifier(specifier):
try:
packaging.specifiers.SpecifierSet(specifier)
except packaging.specifiers.InvalidSpecifier:
raise wtforms.validators.ValidationError(
"Invalid specifier in requirement."
) from None
def command_build(buildfile, output, inputs=None, implicit=None,
order_only=None, commands=None, env=None):
# XXX: Only make some command builds use the console pool?
extra_kwargs = {}
if version in SpecifierSet('>=1.5'):
extra_kwargs['pool'] = 'console'
if not buildfile.has_rule('command'):
buildfile.rule(name='command', command=var('cmd'), **extra_kwargs)
if not buildfile.has_build('PHONY'):
buildfile.build(output='PHONY', rule='phony')
buildfile.build(
output=output,
rule='command',
inputs=inputs,
implicit=iterutils.listify(implicit) + ['PHONY'],
order_only=order_only,
variables={'cmd': Commands(commands, env)}
)
def __init__(self, project_name, specs, extras):
"""DO NOT CALL THIS UNDOCUMENTED METHOD; use Requirement.parse()!"""
self.unsafe_name, project_name = project_name, safe_name(project_name)
self.project_name, self.key = project_name, project_name.lower()
self.specifier = packaging.specifiers.SpecifierSet(
",".join(["".join([x, y]) for x, y in specs])
)
self.specs = specs
self.extras = tuple(map(safe_extra, extras))
self.hashCmp = (
self.key,
self.specifier,
frozenset(self.extras),
)
self.__hash = hash(self.hashCmp)
def _check_required_version(self, required_version, target_version):
if required_version is None:
return True
try:
match_versions = SpecifierSet(required_version)
except InvalidSpecifier:
raise HokusaiError("Could not parse '%s' as a valid version specifier. See https://www.python.org/dev/peps/pep-0440/#version-specifiers" % required_version)
try:
compare_version = Version(target_version)
except InvalidVersion:
raise HokusaiError("Could not parse '%s' as a valid version identifier. See https://www.python.org/dev/peps/pep-0440/#version-scheme" % target_version)
return compare_version in match_versions
def check_specifier(dist, attr, value):
"""Verify that value is a valid version specifier"""
try:
packaging.specifiers.SpecifierSet(value)
except packaging.specifiers.InvalidSpecifier as error:
tmpl = (
"{attr!r} must be a string "
"containing valid version specifiers; {error}"
)
raise DistutilsSetupError(tmpl.format(attr=attr, error=error))