aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrobot-contrib <robot-contrib@yandex-team.com>2024-01-25 09:51:43 +0300
committerrobot-contrib <robot-contrib@yandex-team.com>2024-01-25 10:15:24 +0300
commit42db3295ba5bc7fffa4b289c9010d802e2d7911c (patch)
treec9a78a1b8b9f06c8de4788c1e19c83a35beea59d
parenta47b1fb37eb32d1a5d55d8be2af832cc4406935a (diff)
downloadydb-42db3295ba5bc7fffa4b289c9010d802e2d7911c.tar.gz
Update contrib/python/Jinja2/py3 to 3.1.3
-rw-r--r--contrib/python/Jinja2/py3/.dist-info/METADATA14
-rw-r--r--contrib/python/Jinja2/py3/README.rst2
-rw-r--r--contrib/python/Jinja2/py3/jinja2/__init__.py2
-rw-r--r--contrib/python/Jinja2/py3/jinja2/async_utils.py2
-rw-r--r--contrib/python/Jinja2/py3/jinja2/compiler.py5
-rw-r--r--contrib/python/Jinja2/py3/jinja2/environment.py12
-rw-r--r--contrib/python/Jinja2/py3/jinja2/ext.py20
-rw-r--r--contrib/python/Jinja2/py3/jinja2/filters.py28
-rw-r--r--contrib/python/Jinja2/py3/jinja2/loaders.py36
-rw-r--r--contrib/python/Jinja2/py3/jinja2/nativetypes.py2
-rw-r--r--contrib/python/Jinja2/py3/jinja2/parser.py16
-rw-r--r--contrib/python/Jinja2/py3/jinja2/runtime.py8
-rw-r--r--contrib/python/Jinja2/py3/jinja2/utils.py4
-rw-r--r--contrib/python/Jinja2/py3/tests/test_ext.py13
-rw-r--r--contrib/python/Jinja2/py3/tests/test_filters.py8
-rw-r--r--contrib/python/Jinja2/py3/tests/test_inheritance.py39
-rw-r--r--contrib/python/Jinja2/py3/tests/test_loader.py6
-rw-r--r--contrib/python/Jinja2/py3/ya.make2
-rw-r--r--contrib/python/hypothesis/py3/.dist-info/METADATA2
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/internal/filtering.py51
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/internal/reflection.py4
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/strategies/_internal/collections.py18
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/version.py2
-rw-r--r--contrib/python/hypothesis/py3/ya.make2
-rw-r--r--contrib/python/ydb/py3/.dist-info/METADATA2
-rw-r--r--contrib/python/ydb/py3/ya.make2
-rw-r--r--contrib/python/ydb/py3/ydb/ydb_version.py2
27 files changed, 198 insertions, 106 deletions
diff --git a/contrib/python/Jinja2/py3/.dist-info/METADATA b/contrib/python/Jinja2/py3/.dist-info/METADATA
index f54bb5ca1a..56e942902a 100644
--- a/contrib/python/Jinja2/py3/.dist-info/METADATA
+++ b/contrib/python/Jinja2/py3/.dist-info/METADATA
@@ -1,10 +1,8 @@
Metadata-Version: 2.1
Name: Jinja2
-Version: 3.1.2
+Version: 3.1.3
Summary: A very fast and expressive template engine.
Home-page: https://palletsprojects.com/p/jinja/
-Author: Armin Ronacher
-Author-email: armin.ronacher@active-4.com
Maintainer: Pallets
Maintainer-email: contact@palletsprojects.com
License: BSD-3-Clause
@@ -13,9 +11,7 @@ Project-URL: Documentation, https://jinja.palletsprojects.com/
Project-URL: Changes, https://jinja.palletsprojects.com/changes/
Project-URL: Source Code, https://github.com/pallets/jinja/
Project-URL: Issue Tracker, https://github.com/pallets/jinja/issues/
-Project-URL: Twitter, https://twitter.com/PalletsTeam
Project-URL: Chat, https://discord.gg/pallets
-Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
@@ -27,9 +23,9 @@ Classifier: Topic :: Text Processing :: Markup :: HTML
Requires-Python: >=3.7
Description-Content-Type: text/x-rst
License-File: LICENSE.rst
-Requires-Dist: MarkupSafe (>=2.0)
+Requires-Dist: MarkupSafe >=2.0
Provides-Extra: i18n
-Requires-Dist: Babel (>=2.7) ; extra == 'i18n'
+Requires-Dist: Babel >=2.7 ; extra == 'i18n'
Jinja
=====
@@ -106,8 +102,4 @@ Links
- PyPI Releases: https://pypi.org/project/Jinja2/
- Source Code: https://github.com/pallets/jinja/
- Issue Tracker: https://github.com/pallets/jinja/issues/
-- Website: https://palletsprojects.com/p/jinja/
-- Twitter: https://twitter.com/PalletsTeam
- Chat: https://discord.gg/pallets
-
-
diff --git a/contrib/python/Jinja2/py3/README.rst b/contrib/python/Jinja2/py3/README.rst
index a197aea647..94b22ecabe 100644
--- a/contrib/python/Jinja2/py3/README.rst
+++ b/contrib/python/Jinja2/py3/README.rst
@@ -73,6 +73,4 @@ Links
- PyPI Releases: https://pypi.org/project/Jinja2/
- Source Code: https://github.com/pallets/jinja/
- Issue Tracker: https://github.com/pallets/jinja/issues/
-- Website: https://palletsprojects.com/p/jinja/
-- Twitter: https://twitter.com/PalletsTeam
- Chat: https://discord.gg/pallets
diff --git a/contrib/python/Jinja2/py3/jinja2/__init__.py b/contrib/python/Jinja2/py3/jinja2/__init__.py
index a684093795..8076e72cd1 100644
--- a/contrib/python/Jinja2/py3/jinja2/__init__.py
+++ b/contrib/python/Jinja2/py3/jinja2/__init__.py
@@ -35,4 +35,4 @@ from .utils import pass_environment as pass_environment
from .utils import pass_eval_context as pass_eval_context
from .utils import select_autoescape as select_autoescape
-__version__ = "3.1.2"
+__version__ = "3.1.3"
diff --git a/contrib/python/Jinja2/py3/jinja2/async_utils.py b/contrib/python/Jinja2/py3/jinja2/async_utils.py
index 1a4f3892ce..715d70119b 100644
--- a/contrib/python/Jinja2/py3/jinja2/async_utils.py
+++ b/contrib/python/Jinja2/py3/jinja2/async_utils.py
@@ -74,7 +74,7 @@ async def auto_aiter(
async for item in t.cast("t.AsyncIterable[V]", iterable):
yield item
else:
- for item in t.cast("t.Iterable[V]", iterable):
+ for item in iterable:
yield item
diff --git a/contrib/python/Jinja2/py3/jinja2/compiler.py b/contrib/python/Jinja2/py3/jinja2/compiler.py
index 3458095f54..ff95c807b0 100644
--- a/contrib/python/Jinja2/py3/jinja2/compiler.py
+++ b/contrib/python/Jinja2/py3/jinja2/compiler.py
@@ -993,7 +993,6 @@ class CodeGenerator(NodeVisitor):
# far, we don't have to add a check if something extended
# the template before this one.
if self.extends_so_far > 0:
-
# if we have a known extends we just add a template runtime
# error into the generated code. We could catch that at compile
# time too, but i welcome it not to confuse users by throwing the
@@ -1407,7 +1406,7 @@ class CodeGenerator(NodeVisitor):
if pass_arg is None:
- def finalize(value: t.Any) -> t.Any:
+ def finalize(value: t.Any) -> t.Any: # noqa: F811
return default(env_finalize(value))
else:
@@ -1415,7 +1414,7 @@ class CodeGenerator(NodeVisitor):
if pass_arg == "environment":
- def finalize(value: t.Any) -> t.Any:
+ def finalize(value: t.Any) -> t.Any: # noqa: F811
return default(env_finalize(self.environment, value))
self._finalize = self._FinalizeInfo(finalize, src)
diff --git a/contrib/python/Jinja2/py3/jinja2/environment.py b/contrib/python/Jinja2/py3/jinja2/environment.py
index ea04e8b443..185d33246e 100644
--- a/contrib/python/Jinja2/py3/jinja2/environment.py
+++ b/contrib/python/Jinja2/py3/jinja2/environment.py
@@ -701,7 +701,7 @@ class Environment:
.. versionadded:: 2.5
"""
- return compile(source, filename, "exec") # type: ignore
+ return compile(source, filename, "exec")
@typing.overload
def compile( # type: ignore
@@ -920,7 +920,7 @@ class Environment:
)
def filter_func(x: str) -> bool:
- return "." in x and x.rsplit(".", 1)[1] in extensions # type: ignore
+ return "." in x and x.rsplit(".", 1)[1] in extensions
if filter_func is not None:
names = [name for name in names if filter_func(name)]
@@ -1253,7 +1253,7 @@ class Template:
t.blocks = namespace["blocks"]
# render function and module
- t.root_render_func = namespace["root"] # type: ignore
+ t.root_render_func = namespace["root"]
t._module = None
# debug and loader helpers
@@ -1349,7 +1349,7 @@ class Template:
ctx = self.new_context(dict(*args, **kwargs))
try:
- yield from self.root_render_func(ctx) # type: ignore
+ yield from self.root_render_func(ctx)
except Exception:
yield self.environment.handle_exception()
@@ -1532,7 +1532,7 @@ class TemplateModule:
" API you are using."
)
- body_stream = list(template.root_render_func(context)) # type: ignore
+ body_stream = list(template.root_render_func(context))
self._body_stream = body_stream
self.__dict__.update(context.get_exported())
@@ -1564,7 +1564,7 @@ class TemplateExpression:
def __call__(self, *args: t.Any, **kwargs: t.Any) -> t.Optional[t.Any]:
context = self._template.new_context(dict(*args, **kwargs))
- consume(self._template.root_render_func(context)) # type: ignore
+ consume(self._template.root_render_func(context))
rv = context.vars["result"]
if self._undefined_to_none and isinstance(rv, Undefined):
rv = None
diff --git a/contrib/python/Jinja2/py3/jinja2/ext.py b/contrib/python/Jinja2/py3/jinja2/ext.py
index d5550540cd..fade1fa3bc 100644
--- a/contrib/python/Jinja2/py3/jinja2/ext.py
+++ b/contrib/python/Jinja2/py3/jinja2/ext.py
@@ -291,14 +291,14 @@ class InternationalizationExtension(Extension):
if hasattr(translations, "pgettext"):
# Python < 3.8
- pgettext = translations.pgettext # type: ignore
+ pgettext = translations.pgettext
else:
def pgettext(c: str, s: str) -> str:
return s
if hasattr(translations, "npgettext"):
- npgettext = translations.npgettext # type: ignore
+ npgettext = translations.npgettext
else:
def npgettext(c: str, s: str, p: str, n: int) -> str:
@@ -495,16 +495,26 @@ class InternationalizationExtension(Extension):
parser.stream.expect("variable_end")
elif parser.stream.current.type == "block_begin":
next(parser.stream)
- if parser.stream.current.test("name:endtrans"):
+ block_name = (
+ parser.stream.current.value
+ if parser.stream.current.type == "name"
+ else None
+ )
+ if block_name == "endtrans":
break
- elif parser.stream.current.test("name:pluralize"):
+ elif block_name == "pluralize":
if allow_pluralize:
break
parser.fail(
"a translatable section can have only one pluralize section"
)
+ elif block_name == "trans":
+ parser.fail(
+ "trans blocks can't be nested; did you mean `endtrans`?"
+ )
parser.fail(
- "control structures in translatable sections are not allowed"
+ f"control structures in translatable sections are not allowed; "
+ f"saw `{block_name}`"
)
elif parser.stream.eos:
parser.fail("unclosed translation block")
diff --git a/contrib/python/Jinja2/py3/jinja2/filters.py b/contrib/python/Jinja2/py3/jinja2/filters.py
index ed07c4c0e2..c7ecc9bb68 100644
--- a/contrib/python/Jinja2/py3/jinja2/filters.py
+++ b/contrib/python/Jinja2/py3/jinja2/filters.py
@@ -248,13 +248,17 @@ def do_items(value: t.Union[t.Mapping[K, V], Undefined]) -> t.Iterator[t.Tuple[K
yield from value.items()
+_space_re = re.compile(r"\s", flags=re.ASCII)
+
+
@pass_eval_context
def do_xmlattr(
eval_ctx: "EvalContext", d: t.Mapping[str, t.Any], autospace: bool = True
) -> str:
"""Create an SGML/XML attribute string based on the items in a dict.
- All values that are neither `none` nor `undefined` are automatically
- escaped:
+
+ If any key contains a space, this fails with a ``ValueError``. Values that
+ are neither ``none`` nor ``undefined`` are automatically escaped.
.. sourcecode:: html+jinja
@@ -273,12 +277,22 @@ def do_xmlattr(
As you can see it automatically prepends a space in front of the item
if the filter returned something unless the second parameter is false.
+
+ .. versionchanged:: 3.1.3
+ Keys with spaces are not allowed.
"""
- rv = " ".join(
- f'{escape(key)}="{escape(value)}"'
- for key, value in d.items()
- if value is not None and not isinstance(value, Undefined)
- )
+ items = []
+
+ for key, value in d.items():
+ if value is None or isinstance(value, Undefined):
+ continue
+
+ if _space_re.search(key) is not None:
+ raise ValueError(f"Spaces are not allowed in attributes: '{key}'")
+
+ items.append(f'{escape(key)}="{escape(value)}"')
+
+ rv = " ".join(items)
if autospace and rv:
rv = " " + rv
diff --git a/contrib/python/Jinja2/py3/jinja2/loaders.py b/contrib/python/Jinja2/py3/jinja2/loaders.py
index 261802176a..dfa2ad7ec5 100644
--- a/contrib/python/Jinja2/py3/jinja2/loaders.py
+++ b/contrib/python/Jinja2/py3/jinja2/loaders.py
@@ -16,7 +16,6 @@ from types import ModuleType
from .exceptions import TemplateNotFound
from .utils import internalcode
-from .utils import open_if_exists
if t.TYPE_CHECKING:
from .environment import Environment
@@ -196,29 +195,30 @@ class FileSystemLoader(BaseLoader):
self, environment: "Environment", template: str
) -> t.Tuple[str, str, t.Callable[[], bool]]:
pieces = split_template_path(template)
+
for searchpath in self.searchpath:
# Use posixpath even on Windows to avoid "drive:" or UNC
# segments breaking out of the search directory.
filename = posixpath.join(searchpath, *pieces)
- f = open_if_exists(filename)
- if f is None:
- continue
- try:
- contents = f.read().decode(self.encoding)
- finally:
- f.close()
- mtime = os.path.getmtime(filename)
+ if os.path.isfile(filename):
+ break
+ else:
+ raise TemplateNotFound(template)
- def uptodate() -> bool:
- try:
- return os.path.getmtime(filename) == mtime
- except OSError:
- return False
+ with open(filename, encoding=self.encoding) as f:
+ contents = f.read()
- # Use normpath to convert Windows altsep to sep.
- return contents, os.path.normpath(filename), uptodate
- raise TemplateNotFound(template)
+ mtime = os.path.getmtime(filename)
+
+ def uptodate() -> bool:
+ try:
+ return os.path.getmtime(filename) == mtime
+ except OSError:
+ return False
+
+ # Use normpath to convert Windows altsep to sep.
+ return contents, os.path.normpath(filename), uptodate
def list_templates(self) -> t.List[str]:
found = set()
@@ -412,7 +412,7 @@ class PackageLoader(BaseLoader):
)
offset = len(prefix)
- for name in self._loader._files.keys(): # type: ignore
+ for name in self._loader._files.keys():
# Find names under the templates directory that aren't directories.
if name.startswith(prefix) and name[-1] != os.path.sep:
results.append(name[offset:].replace(os.path.sep, "/"))
diff --git a/contrib/python/Jinja2/py3/jinja2/nativetypes.py b/contrib/python/Jinja2/py3/jinja2/nativetypes.py
index ac08610348..71db8cc31f 100644
--- a/contrib/python/Jinja2/py3/jinja2/nativetypes.py
+++ b/contrib/python/Jinja2/py3/jinja2/nativetypes.py
@@ -106,7 +106,7 @@ class NativeTemplate(Template):
try:
return self.environment_class.concat( # type: ignore
- self.root_render_func(ctx) # type: ignore
+ self.root_render_func(ctx)
)
except Exception:
return self.environment.handle_exception()
diff --git a/contrib/python/Jinja2/py3/jinja2/parser.py b/contrib/python/Jinja2/py3/jinja2/parser.py
index cefce2dfa1..3354bc9339 100644
--- a/contrib/python/Jinja2/py3/jinja2/parser.py
+++ b/contrib/python/Jinja2/py3/jinja2/parser.py
@@ -311,12 +311,14 @@ class Parser:
# enforce that required blocks only contain whitespace or comments
# by asserting that the body, if not empty, is just TemplateData nodes
# with whitespace data
- if node.required and not all(
- isinstance(child, nodes.TemplateData) and child.data.isspace()
- for body in node.body
- for child in body.nodes # type: ignore
- ):
- self.fail("Required blocks can only contain comments or whitespace")
+ if node.required:
+ for body_node in node.body:
+ if not isinstance(body_node, nodes.Output) or any(
+ not isinstance(output_node, nodes.TemplateData)
+ or not output_node.data.isspace()
+ for output_node in body_node.nodes
+ ):
+ self.fail("Required blocks can only contain comments or whitespace")
self.stream.skip_if("name:" + node.name)
return node
@@ -857,7 +859,7 @@ class Parser:
else:
args.append(None)
- return nodes.Slice(lineno=lineno, *args)
+ return nodes.Slice(lineno=lineno, *args) # noqa: B026
def parse_call_args(self) -> t.Tuple:
token = self.stream.expect("lparen")
diff --git a/contrib/python/Jinja2/py3/jinja2/runtime.py b/contrib/python/Jinja2/py3/jinja2/runtime.py
index 985842b284..58a540ba3f 100644
--- a/contrib/python/Jinja2/py3/jinja2/runtime.py
+++ b/contrib/python/Jinja2/py3/jinja2/runtime.py
@@ -272,9 +272,9 @@ class Context:
# Allow callable classes to take a context
if (
hasattr(__obj, "__call__") # noqa: B004
- and _PassArg.from_obj(__obj.__call__) is not None # type: ignore
+ and _PassArg.from_obj(__obj.__call__) is not None
):
- __obj = __obj.__call__ # type: ignore
+ __obj = __obj.__call__
pass_arg = _PassArg.from_obj(__obj)
@@ -927,9 +927,7 @@ def make_logging_undefined(
logger.addHandler(logging.StreamHandler(sys.stderr))
def _log_message(undef: Undefined) -> None:
- logger.warning( # type: ignore
- "Template variable warning: %s", undef._undefined_message
- )
+ logger.warning("Template variable warning: %s", undef._undefined_message)
class LoggingUndefined(base): # type: ignore
__slots__ = ()
diff --git a/contrib/python/Jinja2/py3/jinja2/utils.py b/contrib/python/Jinja2/py3/jinja2/utils.py
index 9b5f5a50eb..18914a58fd 100644
--- a/contrib/python/Jinja2/py3/jinja2/utils.py
+++ b/contrib/python/Jinja2/py3/jinja2/utils.py
@@ -182,7 +182,7 @@ def object_type_repr(obj: t.Any) -> str:
def pformat(obj: t.Any) -> str:
"""Format an object using :func:`pprint.pformat`."""
- from pprint import pformat # type: ignore
+ from pprint import pformat
return pformat(obj)
@@ -259,7 +259,7 @@ def urlize(
if trim_url_limit is not None:
def trim_url(x: str) -> str:
- if len(x) > trim_url_limit: # type: ignore
+ if len(x) > trim_url_limit:
return f"{x[:trim_url_limit]}..."
return x
diff --git a/contrib/python/Jinja2/py3/tests/test_ext.py b/contrib/python/Jinja2/py3/tests/test_ext.py
index 2e842e0ab5..0b48ca2586 100644
--- a/contrib/python/Jinja2/py3/tests/test_ext.py
+++ b/contrib/python/Jinja2/py3/tests/test_ext.py
@@ -7,6 +7,7 @@ from jinja2 import DictLoader
from jinja2 import Environment
from jinja2 import nodes
from jinja2 import pass_context
+from jinja2 import TemplateSyntaxError
from jinja2.exceptions import TemplateAssertionError
from jinja2.ext import Extension
from jinja2.lexer import count_newlines
@@ -468,6 +469,18 @@ class TestInternationalization:
(3, "npgettext", ("babel", "%(users)s user", "%(users)s users", None), []),
]
+ def test_nested_trans_error(self):
+ s = "{% trans %}foo{% trans %}{% endtrans %}"
+ with pytest.raises(TemplateSyntaxError) as excinfo:
+ i18n_env.from_string(s)
+ assert "trans blocks can't be nested" in str(excinfo.value)
+
+ def test_trans_block_error(self):
+ s = "{% trans %}foo{% wibble bar %}{% endwibble %}{% endtrans %}"
+ with pytest.raises(TemplateSyntaxError) as excinfo:
+ i18n_env.from_string(s)
+ assert "saw `wibble`" in str(excinfo.value)
+
class TestScope:
def test_basic_scope_behavior(self):
diff --git a/contrib/python/Jinja2/py3/tests/test_filters.py b/contrib/python/Jinja2/py3/tests/test_filters.py
index 73f0f0be3c..f50ed13ab5 100644
--- a/contrib/python/Jinja2/py3/tests/test_filters.py
+++ b/contrib/python/Jinja2/py3/tests/test_filters.py
@@ -474,6 +474,12 @@ class TestFilter:
assert 'bar="23"' in out
assert 'blub:blub="&lt;?&gt;"' in out
+ def test_xmlattr_key_with_spaces(self, env):
+ with pytest.raises(ValueError, match="Spaces are not allowed"):
+ env.from_string(
+ "{{ {'src=1 onerror=alert(1)': 'my_class'}|xmlattr }}"
+ ).render()
+
def test_sort1(self, env):
tmpl = env.from_string("{{ [2, 3, 1]|sort }}|{{ [2, 3, 1]|sort(true) }}")
assert tmpl.render() == "[1, 2, 3]|[3, 2, 1]"
@@ -870,4 +876,6 @@ class TestFilter:
with pytest.raises(TemplateRuntimeError, match="No filter named 'f'"):
t1.render(x=42)
+
+ with pytest.raises(TemplateRuntimeError, match="No filter named 'f'"):
t2.render(x=42)
diff --git a/contrib/python/Jinja2/py3/tests/test_inheritance.py b/contrib/python/Jinja2/py3/tests/test_inheritance.py
index 0c20d4da7d..0a525e7ac9 100644
--- a/contrib/python/Jinja2/py3/tests/test_inheritance.py
+++ b/contrib/python/Jinja2/py3/tests/test_inheritance.py
@@ -287,26 +287,34 @@ class TestInheritance:
env = Environment(
loader=DictLoader(
{
- "default": "{% block x required %}data {# #}{% endblock %}",
- "default1": "{% block x required %}{% block y %}"
- "{% endblock %} {% endblock %}",
- "default2": "{% block x required %}{% if true %}"
- "{% endif %} {% endblock %}",
- "level1": "{% if default %}{% extends default %}"
- "{% else %}{% extends 'default' %}{% endif %}"
- "{%- block x %}CHILD{% endblock %}",
+ "empty": "{% block x required %}{% endblock %}",
+ "blank": "{% block x required %} {# c #}{% endblock %}",
+ "text": "{% block x required %}data {# c #}{% endblock %}",
+ "block": "{% block x required %}{% block y %}"
+ "{% endblock %}{% endblock %}",
+ "if": "{% block x required %}{% if true %}"
+ "{% endif %}{% endblock %}",
+ "top": "{% extends t %}{% block x %}CHILD{% endblock %}",
}
)
)
- t = env.get_template("level1")
+ t = env.get_template("top")
+ assert t.render(t="empty") == "CHILD"
+ assert t.render(t="blank") == "CHILD"
- with pytest.raises(
+ required_block_check = pytest.raises(
TemplateSyntaxError,
match="Required blocks can only contain comments or whitespace",
- ):
- assert t.render(default="default")
- assert t.render(default="default2")
- assert t.render(default="default3")
+ )
+
+ with required_block_check:
+ t.render(t="text")
+
+ with required_block_check:
+ t.render(t="block")
+
+ with required_block_check:
+ t.render(t="if")
def test_required_with_scope(self, env):
env = Environment(
@@ -347,8 +355,11 @@ class TestInheritance:
)
)
tmpl = env.get_template("child")
+
with pytest.raises(TemplateSyntaxError):
tmpl.render(default="default1", seq=list(range(3)))
+
+ with pytest.raises(TemplateSyntaxError):
tmpl.render(default="default2", seq=list(range(3)))
diff --git a/contrib/python/Jinja2/py3/tests/test_loader.py b/contrib/python/Jinja2/py3/tests/test_loader.py
index a396e18fec..d3b4ddf1ba 100644
--- a/contrib/python/Jinja2/py3/tests/test_loader.py
+++ b/contrib/python/Jinja2/py3/tests/test_loader.py
@@ -186,6 +186,7 @@ class TestFileSystemLoader:
class TestModuleLoader:
archive = None
+ mod_env = None
def compile_down(self, prefix_loader, zip="deflated"):
log = []
@@ -199,13 +200,14 @@ class TestModuleLoader:
self.mod_env = Environment(loader=loaders.ModuleLoader(self.archive))
return "".join(log)
- def teardown(self):
- if hasattr(self, "mod_env"):
+ def teardown_method(self):
+ if self.archive is not None:
if os.path.isfile(self.archive):
os.remove(self.archive)
else:
shutil.rmtree(self.archive)
self.archive = None
+ self.mod_env = None
def test_log(self, prefix_loader):
log = self.compile_down(prefix_loader)
diff --git a/contrib/python/Jinja2/py3/ya.make b/contrib/python/Jinja2/py3/ya.make
index 67ba20df0c..2c15cb57d4 100644
--- a/contrib/python/Jinja2/py3/ya.make
+++ b/contrib/python/Jinja2/py3/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(3.1.2)
+VERSION(3.1.3)
LICENSE(BSD-3-Clause)
diff --git a/contrib/python/hypothesis/py3/.dist-info/METADATA b/contrib/python/hypothesis/py3/.dist-info/METADATA
index 15385afbc9..bf3a10e9cc 100644
--- a/contrib/python/hypothesis/py3/.dist-info/METADATA
+++ b/contrib/python/hypothesis/py3/.dist-info/METADATA
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: hypothesis
-Version: 6.92.6
+Version: 6.92.7
Summary: A library for property-based testing
Home-page: https://hypothesis.works
Author: David R. MacIver and Zac Hatfield-Dodds
diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/filtering.py b/contrib/python/hypothesis/py3/hypothesis/internal/filtering.py
index 8af37e453b..4ba92b1da8 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/filtering.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/filtering.py
@@ -73,6 +73,14 @@ def convert(node: ast.AST, argname: str) -> object:
if node.id != argname:
raise ValueError("Non-local variable")
return ARG
+ if isinstance(node, ast.Call):
+ if (
+ isinstance(node.func, ast.Name)
+ and node.func.id == "len"
+ and len(node.args) == 1
+ ):
+ # error unless comparison is to the len *of the lambda arg*
+ return convert(node.args[0], argname)
return ast.literal_eval(node)
@@ -86,26 +94,28 @@ def comp_to_kwargs(x: ast.AST, op: ast.AST, y: ast.AST, *, argname: str) -> dict
# (and we can't even do `arg == arg`, because what if it's NaN?)
raise ValueError("Can't analyse this comparison")
+ of_len = {"len": True} if isinstance(x, ast.Call) or isinstance(y, ast.Call) else {}
+
if isinstance(op, ast.Lt):
if a is ARG:
- return {"max_value": b, "exclude_max": True}
- return {"min_value": a, "exclude_min": True}
+ return {"max_value": b, "exclude_max": True, **of_len}
+ return {"min_value": a, "exclude_min": True, **of_len}
elif isinstance(op, ast.LtE):
if a is ARG:
- return {"max_value": b}
- return {"min_value": a}
+ return {"max_value": b, **of_len}
+ return {"min_value": a, **of_len}
elif isinstance(op, ast.Eq):
if a is ARG:
- return {"min_value": b, "max_value": b}
- return {"min_value": a, "max_value": a}
+ return {"min_value": b, "max_value": b, **of_len}
+ return {"min_value": a, "max_value": a, **of_len}
elif isinstance(op, ast.GtE):
if a is ARG:
- return {"min_value": b}
- return {"max_value": a}
+ return {"min_value": b, **of_len}
+ return {"max_value": a, **of_len}
elif isinstance(op, ast.Gt):
if a is ARG:
- return {"min_value": b, "exclude_min": True}
- return {"max_value": a, "exclude_max": True}
+ return {"min_value": b, "exclude_min": True, **of_len}
+ return {"max_value": a, "exclude_max": True, **of_len}
raise ValueError("Unhandled comparison operator") # e.g. ast.Ne
@@ -120,6 +130,9 @@ def merge_preds(*con_predicates: ConstructivePredicate) -> ConstructivePredicate
}
predicate = None
for kw, p in con_predicates:
+ assert (
+ not p or not predicate or p is predicate
+ ), "Can't merge two partially-constructive preds"
predicate = p or predicate
if "min_value" in kw:
if kw["min_value"] > base["min_value"]:
@@ -134,6 +147,11 @@ def merge_preds(*con_predicates: ConstructivePredicate) -> ConstructivePredicate
elif kw["max_value"] == base["max_value"]:
base["exclude_max"] |= kw.get("exclude_max", False)
+ has_len = {"len" in kw for kw, _ in con_predicates}
+ assert len(has_len) == 1, "can't mix numeric with length constraints"
+ if has_len == {True}:
+ base["len"] = True
+
if not base["exclude_min"]:
del base["exclude_min"]
if base["min_value"] == -math.inf:
@@ -154,6 +172,8 @@ def numeric_bounds_from_ast(
{"min_value": 0}, None
>>> lambda x: x < 10
{"max_value": 10, "exclude_max": True}, None
+ >>> lambda x: len(x) >= 5
+ {"min_value": 5, "len": True}, None
>>> lambda x: x >= y
{}, lambda x: x >= y
@@ -169,7 +189,10 @@ def numeric_bounds_from_ast(
for comp in comparisons:
try:
kwargs = comp_to_kwargs(*comp, argname=argname)
- bounds.append(ConstructivePredicate(kwargs, None))
+ # Because `len` could be redefined in the enclosing scope, we *always*
+ # have to apply the condition as a filter, in addition to rewriting.
+ pred = fallback.predicate if "len" in kwargs else None
+ bounds.append(ConstructivePredicate(kwargs, pred))
except ValueError:
bounds.append(fallback)
return merge_preds(*bounds)
@@ -209,6 +232,9 @@ def get_numeric_predicate_bounds(predicate: Predicate) -> ConstructivePredicate:
operator.eq: {"min_value": arg, "max_value": arg}, # lambda x: arg == x
operator.ge: {"max_value": arg}, # lambda x: arg >= x
operator.gt: {"max_value": arg, "exclude_max": True}, # lambda x: arg > x
+ # Special-case our default predicates for length bounds
+ min_len: {"min_value": arg, "len": True},
+ max_len: {"max_value": arg, "len": True},
}
if predicate.func in options:
return ConstructivePredicate(options[predicate.func], None)
@@ -270,7 +296,8 @@ def get_integer_predicate_bounds(predicate: Predicate) -> ConstructivePredicate:
elif kwargs.get("exclude_max", False):
kwargs["max_value"] = int(kwargs["max_value"]) - 1
- kwargs = {k: v for k, v in kwargs.items() if k in {"min_value", "max_value"}}
+ kw_categories = {"min_value", "max_value", "len"}
+ kwargs = {k: v for k, v in kwargs.items() if k in kw_categories}
return ConstructivePredicate(kwargs, predicate)
diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/reflection.py b/contrib/python/hypothesis/py3/hypothesis/internal/reflection.py
index 2f0480c987..d5ea7161f3 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/reflection.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/reflection.py
@@ -19,7 +19,7 @@ import re
import sys
import textwrap
import types
-from functools import wraps
+from functools import partial, wraps
from io import StringIO
from keyword import iskeyword
from tokenize import COMMENT, detect_encoding, generate_tokens, untokenize
@@ -432,6 +432,8 @@ def extract_lambda_source(f):
def get_pretty_function_description(f):
+ if isinstance(f, partial):
+ return pretty(f)
if not hasattr(f, "__name__"):
return repr(f)
name = f.__name__
diff --git a/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/collections.py b/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/collections.py
index 2bee499ac2..1f86f37a42 100644
--- a/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/collections.py
+++ b/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/collections.py
@@ -15,6 +15,7 @@ from hypothesis.errors import InvalidArgument
from hypothesis.internal.conjecture import utils as cu
from hypothesis.internal.conjecture.junkdrawer import LazySequenceCopy
from hypothesis.internal.conjecture.utils import combine_labels
+from hypothesis.internal.filtering import get_integer_predicate_bounds
from hypothesis.internal.reflection import is_identity_function
from hypothesis.strategies._internal.strategies import (
T3,
@@ -199,7 +200,22 @@ class ListStrategy(SearchStrategy):
new = copy.copy(self)
new.min_size = 1
return new
- return super().filter(condition)
+
+ kwargs, pred = get_integer_predicate_bounds(condition)
+ if kwargs.get("len") and ("min_value" in kwargs or "max_value" in kwargs):
+ new = copy.copy(self)
+ new.min_size = max(self.min_size, kwargs.get("min_value", self.min_size))
+ new.max_size = min(self.max_size, kwargs.get("max_value", self.max_size))
+ # Recompute average size; this is cheaper than making it into a property.
+ new.average_size = min(
+ max(new.min_size * 2, new.min_size + 5),
+ 0.5 * (new.min_size + new.max_size),
+ )
+ if pred is None:
+ return new
+ return SearchStrategy.filter(new, condition)
+
+ return SearchStrategy.filter(self, condition)
class UniqueListStrategy(ListStrategy):
diff --git a/contrib/python/hypothesis/py3/hypothesis/version.py b/contrib/python/hypothesis/py3/hypothesis/version.py
index 382bffeb8b..cd924cc7a7 100644
--- a/contrib/python/hypothesis/py3/hypothesis/version.py
+++ b/contrib/python/hypothesis/py3/hypothesis/version.py
@@ -8,5 +8,5 @@
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at https://mozilla.org/MPL/2.0/.
-__version_info__ = (6, 92, 6)
+__version_info__ = (6, 92, 7)
__version__ = ".".join(map(str, __version_info__))
diff --git a/contrib/python/hypothesis/py3/ya.make b/contrib/python/hypothesis/py3/ya.make
index 2a6ae3478d..6616c6d3b9 100644
--- a/contrib/python/hypothesis/py3/ya.make
+++ b/contrib/python/hypothesis/py3/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(6.92.6)
+VERSION(6.92.7)
LICENSE(MPL-2.0)
diff --git a/contrib/python/ydb/py3/.dist-info/METADATA b/contrib/python/ydb/py3/.dist-info/METADATA
index 058eb80b41..394559f8df 100644
--- a/contrib/python/ydb/py3/.dist-info/METADATA
+++ b/contrib/python/ydb/py3/.dist-info/METADATA
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: ydb
-Version: 3.7.0
+Version: 3.7.1
Summary: YDB Python SDK
Home-page: http://github.com/ydb-platform/ydb-python-sdk
Author: Yandex LLC
diff --git a/contrib/python/ydb/py3/ya.make b/contrib/python/ydb/py3/ya.make
index f92572fa82..af4882e7d0 100644
--- a/contrib/python/ydb/py3/ya.make
+++ b/contrib/python/ydb/py3/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(3.7.0)
+VERSION(3.7.1)
LICENSE(Apache-2.0)
diff --git a/contrib/python/ydb/py3/ydb/ydb_version.py b/contrib/python/ydb/py3/ydb/ydb_version.py
index 709cb0a9e5..02e0768899 100644
--- a/contrib/python/ydb/py3/ydb/ydb_version.py
+++ b/contrib/python/ydb/py3/ydb/ydb_version.py
@@ -1 +1 @@
-VERSION = "3.7.0"
+VERSION = "3.7.1"