Skip to content
Myr

switch to pyproject.toml (#1793)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by GitHub · parents 048a068, 8ed8e1d · Browse files · 17 files+161 added−158 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

17 files+161 added−158 removed

  • other:+161 added−158 removed

17 files+161 added−158 removed

modified:.github/workflows/tests.yaml+1 added-1 removed
modified:src/jinja2/async_utils.py+1 added-1 removed
45 unmodified lines
4647 if need_eval_context:48 wrapper = pass_eval_context(wrapper)4950 wrapper.jinja_async_variant = True50 wrapper.jinja_async_variant = True # type: ignore[attr-defined]51 return wrapper5253 return decorator54
30 unmodified lines
modified:src/jinja2/environment.py+7 added-5 removed
77 unmodified lines
787980def create_cache(81 size: int,82) -> t.Optional[t.MutableMapping[t.Tuple[weakref.ref, str], "Template"]]:82) -> t.Optional[t.MutableMapping[t.Tuple["weakref.ref[BaseLoader]", str], "Template"]]:83 """Return the cache class for the given size."""84 if size == 0:85 return None86
3 unmodified lines
90 return LRUCache(size) # type: ignore919293def copy_cache(94 cache: t.Optional[t.MutableMapping],95) -> t.Optional[t.MutableMapping[t.Tuple[weakref.ref, str], "Template"]]:94 cache: t.Optional[95 t.MutableMapping[t.Tuple["weakref.ref[BaseLoader]", str], "Template"]96 ],97) -> t.Optional[t.MutableMapping[t.Tuple["weakref.ref[BaseLoader]", str], "Template"]]:98 """Create an empty copy of the given cache."""99 if cache is None:100 return None101
713 unmodified lines
815 return TemplateExpression(template, undefined_to_none)816817 def compile_templates(818 self,817 target: t.Union[str, os.PathLike],819 target: t.Union[str, "os.PathLike[str]"],820 extensions: t.Optional[t.Collection[str]] = None,821 filter_func: t.Optional[t.Callable[[str], bool]] = None,822 zip: t.Optional[str] = "deflated",823 log_function: t.Optional[t.Callable[[str], None]] = None,
765 unmodified lines
1589 self.disable_buffering()15901591 def dump(1592 self,1591 fp: t.Union[str, t.IO],1593 fp: t.Union[str, t.IO[t.Any]],1594 encoding: t.Optional[str] = None,1595 errors: t.Optional[str] = "strict",1596 ) -> None:1597 """Dump the complete stream into a file or file-like object.
72 unmodified lines
modified:src/jinja2/filters.py+23 added-19 removed
536 unmodified lines
537538@pass_eval_context539def sync_do_join(540 eval_ctx: "EvalContext",541 value: t.Iterable,541 value: t.Iterable[t.Any],542 d: str = "",543 attribute: t.Optional[t.Union[str, int]] = None,544) -> str:545 """Return a string which is the concatenation of the strings in the
49 unmodified lines
595596@async_variant(sync_do_join) # type: ignore597async def do_join(598 eval_ctx: "EvalContext",599 value: t.Union[t.AsyncIterable, t.Iterable],599 value: t.Union[t.AsyncIterable[t.Any], t.Iterable[t.Any]],600 d: str = "",601 attribute: t.Optional[t.Union[str, int]] = None,602) -> str:603 return sync_do_join(eval_ctx, await auto_to_list(value), d, attribute)
541 unmodified lines
114511461147class _GroupTuple(t.NamedTuple):1148 grouper: t.Any1149 list: t.List1149 list: t.List[t.Any]11501151 # Use the regular tuple repr to hide this subclass if users print1152 # out the value during debugging.1153 def __repr__(self) -> str:
247 unmodified lines
140114021403@typing.overload1404def sync_do_map(1405 context: "Context", value: t.Iterable, name: str, *args: t.Any, **kwargs: t.Any1406) -> t.Iterable:1405 context: "Context",1406 value: t.Iterable[t.Any],1407 name: str,1408 *args: t.Any,1409 **kwargs: t.Any,1410) -> t.Iterable[t.Any]:1411 ...141214131414@typing.overload1415def sync_do_map(1416 context: "Context",1413 value: t.Iterable,1417 value: t.Iterable[t.Any],1418 *,1419 attribute: str = ...,1420 default: t.Optional[t.Any] = None,1417) -> t.Iterable:1421) -> t.Iterable[t.Any]:1422 ...142314241425@pass_context1426def sync_do_map(1423 context: "Context", value: t.Iterable, *args: t.Any, **kwargs: t.Any1424) -> t.Iterable:1427 context: "Context", value: t.Iterable[t.Any], *args: t.Any, **kwargs: t.Any1428) -> t.Iterable[t.Any]:1429 """Applies a filter on a sequence of objects or looks up an attribute.1430 This is useful when dealing with lists of objects but you are really1431 only interested in a certain value of it.1432
41 unmodified lines
14741475@typing.overload1476def do_map(1477 context: "Context",1474 value: t.Union[t.AsyncIterable, t.Iterable],1478 value: t.Union[t.AsyncIterable[t.Any], t.Iterable[t.Any]],1479 name: str,1480 *args: t.Any,1481 **kwargs: t.Any,1478) -> t.Iterable:1482) -> t.Iterable[t.Any]:1483 ...148414851486@typing.overload1487def do_map(1488 context: "Context",1485 value: t.Union[t.AsyncIterable, t.Iterable],1489 value: t.Union[t.AsyncIterable[t.Any], t.Iterable[t.Any]],1490 *,1491 attribute: str = ...,1492 default: t.Optional[t.Any] = None,1489) -> t.Iterable:1493) -> t.Iterable[t.Any]:1494 ...149514961497@async_variant(sync_do_map) # type: ignore1498async def do_map(1499 context: "Context",1496 value: t.Union[t.AsyncIterable, t.Iterable],1500 value: t.Union[t.AsyncIterable[t.Any], t.Iterable[t.Any]],1501 *args: t.Any,1502 **kwargs: t.Any,1499) -> t.AsyncIterable:1503) -> t.AsyncIterable[t.Any]:1504 if value:1505 func = prepare_map(context, args, kwargs)15061507 async for item in auto_aiter(value):
184 unmodified lines
1692 return htmlsafe_json_dumps(value, dumps=dumps, **kwargs)169316941695def prepare_map(1692 context: "Context", args: t.Tuple, kwargs: t.Dict[str, t.Any]1696 context: "Context", args: t.Tuple[t.Any, ...], kwargs: t.Dict[str, t.Any]1697) -> t.Callable[[t.Any], t.Any]:1698 if not args and "attribute" in kwargs:1699 attribute = kwargs.pop("attribute")1700 default = kwargs.pop("default", None)
20 unmodified lines
172117221723def prepare_select_or_reject(1724 context: "Context",1721 args: t.Tuple,1725 args: t.Tuple[t.Any, ...],1726 kwargs: t.Dict[str, t.Any],1727 modfunc: t.Callable[[t.Any], t.Any],1728 lookup_attr: bool,1729) -> t.Callable[[t.Any], t.Any]:
26 unmodified lines
17561757def select_or_reject(1758 context: "Context",1759 value: "t.Iterable[V]",1756 args: t.Tuple,1760 args: t.Tuple[t.Any, ...],1761 kwargs: t.Dict[str, t.Any],1762 modfunc: t.Callable[[t.Any], t.Any],1763 lookup_attr: bool,1764) -> "t.Iterator[V]":
7 unmodified lines
17721773async def async_select_or_reject(1774 context: "Context",1775 value: "t.Union[t.AsyncIterable[V], t.Iterable[V]]",1772 args: t.Tuple,1776 args: t.Tuple[t.Any, ...],1777 kwargs: t.Dict[str, t.Any],1778 modfunc: t.Callable[[t.Any], t.Any],1779 lookup_attr: bool,1780) -> "t.AsyncIterator[V]":
64 unmodified lines
modified:src/jinja2/lexer.py+1 added-1 removed
445 unmodified lines
446447 return lexer448449450class OptionalLStrip(tuple):450class OptionalLStrip(tuple): # type: ignore[type-arg]451 """A special tuple for marking a point in the state that can have452 lstrip applied.453 """454
412 unmodified lines
modified:src/jinja2/loaders.py+7 added-2 removed
175 unmodified lines
176 """177178 def __init__(179 self,180 searchpath: t.Union[str, os.PathLike, t.Sequence[t.Union[str, os.PathLike]]],180 searchpath: t.Union[181 str, "os.PathLike[str]", t.Sequence[t.Union[str, "os.PathLike[str]"]]182 ],183 encoding: str = "utf-8",184 followlinks: bool = False,185 ) -> None:186 if not isinstance(searchpath, abc.Iterable) or isinstance(searchpath, str):
412 unmodified lines
599600 has_source_access = False601602 def __init__(601 self, path: t.Union[str, os.PathLike, t.Sequence[t.Union[str, os.PathLike]]]603 self,604 path: t.Union[605 str, "os.PathLike[str]", t.Sequence[t.Union[str, "os.PathLike[str]"]]606 ],607 ) -> None:608 package_name = f"_jinja2_module_templates_{id(self):x}"609610 # create a fake module that looks for the templates in the
53 unmodified lines
modified:src/jinja2/nodes.py+1 added-1 removed
54 unmodified lines
55 automatically forwarded to the child."""5657 def __new__(mcs, name, bases, d): # type: ignore58 for attr in "fields", "attributes":59 storage = []59 storage: t.List[t.Any] = []60 storage.extend(getattr(bases[0] if bases else object, attr, ()))61 storage.extend(d.get(attr, ()))62 assert len(bases) <= 1, "multiple inheritance not allowed"63 assert len(storage) == len(set(storage)), "layout conflict"
1141 unmodified lines
modified:src/jinja2/parser.py+9 added-2 removed
857 unmodified lines
858 args.append(None)859860 return nodes.Slice(lineno=lineno, *args)861862 def parse_call_args(self) -> t.Tuple:862 def parse_call_args(863 self,864 ) -> t.Tuple[865 t.List[nodes.Expr],866 t.List[nodes.Keyword],867 t.Union[nodes.Expr, None],868 t.Union[nodes.Expr, None],869 ]:870 token = self.stream.expect("lparen")871 args = []872 kwargs = []873 dyn_args = None
82 unmodified lines
956 while self.stream.current.type == "dot":957 next(self.stream)958 name += "." + self.stream.expect("name").value959 dyn_args = dyn_kwargs = None953 kwargs = []960 kwargs: t.List[nodes.Keyword] = []961 if self.stream.current.type == "lparen":962 args, kwargs, dyn_args, dyn_kwargs = self.parse_call_args()963 elif self.stream.current.type in {964 "name",
75 unmodified lines
modified:src/jinja2/runtime.py+4 added-1 removed
257 unmodified lines
258 return dict(self.parent, **self.vars)259260 @internalcode261 def call(262 __self, __obj: t.Callable, *args: t.Any, **kwargs: t.Any # noqa: B902262 __self, # noqa: B902263 __obj: t.Callable[..., t.Any],264 *args: t.Any,265 **kwargs: t.Any,266 ) -> t.Union[t.Any, "Undefined"]:267 """Call the callable with the arguments and keyword arguments268 provided but inject the active context or environment as first269 argument if the callable has :func:`pass_context` or
787 unmodified lines
modified:src/jinja2/sandbox.py+3 added-3 removed
35 unmodified lines
3637#: unsafe attributes on async generators38UNSAFE_ASYNC_GENERATOR_ATTRIBUTES = {"ag_code", "ag_frame"}3940_mutable_spec: t.Tuple[t.Tuple[t.Type, t.FrozenSet[str]], ...] = (40_mutable_spec: t.Tuple[t.Tuple[t.Type[t.Any], t.FrozenSet[str]], ...] = (41 (42 abc.MutableSet,43 frozenset(44 [
34 unmodified lines
79 ),80)818283def inspect_format_method(callable: t.Callable) -> t.Optional[str]:83def inspect_format_method(callable: t.Callable[..., t.Any]) -> t.Optional[str]:84 if not isinstance(85 callable, (types.MethodType, types.BuiltinMethodType)86 ) or callable.__name__ not in ("format", "format_map"):87 return None
261 unmodified lines
349 self,350 s: str,351 args: t.Tuple[t.Any, ...],352 kwargs: t.Dict[str, t.Any],353 format_func: t.Optional[t.Callable] = None,353 format_func: t.Optional[t.Callable[..., t.Any]] = None,354 ) -> str:355 """If a format call is detected, then this is routed through this356 method so that our safety sandbox can be used for it.357 """
71 unmodified lines
modified:src/jinja2/tests.py+1 added-1 removed
202 unmodified lines
203 """Check if the value is escaped."""204 return hasattr(value, "__html__")205206207def test_in(value: t.Any, seq: t.Container) -> bool:207def test_in(value: t.Any, seq: t.Container[t.Any]) -> bool:208 """Check if value is in seq.209210 .. versionadded:: 2.10211 """
44 unmodified lines
modified:src/jinja2/utils.py+4 added-2 removed
150 unmodified lines
151 if not silent:152 raise153154155def open_if_exists(filename: str, mode: str = "rb") -> t.Optional[t.IO]:155def open_if_exists(filename: str, mode: str = "rb") -> t.Optional[t.IO[t.Any]]:156 """Returns a file descriptor for the filename if that file exists,157 otherwise ``None``.158 """159 if not os.path.isfile(filename):
289 unmodified lines
449 def __setstate__(self, d: t.Mapping[str, t.Any]) -> None:450 self.__dict__.update(d)451 self._postinit()452453 def __getnewargs__(self) -> t.Tuple:453 def __getnewargs__(454 self,455 ) -> t.Tuple[int,]:456 return (self.capacity,)457458 def copy(self) -> "LRUCache":459 """Return a shallow copy of the instance."""
298 unmodified lines
added:.flake8+28 added
1[flake8]2extend-select =3 # bugbear4 B5 # bugbear opinions6 B97 # implicit str concat8 ISC9extend-ignore =10 # slice notation whitespace, invalid11 E20312 # line length, handled by bugbear B95013 E50114 # bare except, handled by bugbear B00115 E72216 # zip with strict=, requires python >= 3.1017 B90518 # string formatting opinion, B028 renamed to B90719 B02820 B90721# up to 88 allowed by bugbear B95022max-line-length = 8023per-file-ignores =24 # __init__ exports names25 src/jinja2/__init__.py: F40126 # not relevant to jinja's compiler27 src/jinja2/compiler.py: B90628 src/jinja2/idtracking.py: B906
modified:CHANGES.rst+3 added
3 unmodified lines
4-------------56Unreleased78- Use modern packaging metadata with ``pyproject.toml`` instead of ``setup.cfg``.9 :pr:`1793`101112Version 3.1.213-------------1415Released 2022-04-28
969 unmodified lines
added:pyproject.toml+68 added
1[project]2name = "Jinja2"3description = "A very fast and expressive template engine."4readme = "README.rst"5license = {text = "BSD-3-Clause"}6maintainers = [{name = "Pallets", email = "contact@palletsprojects.com"}]7authors = [{name = "Armin Ronacher", email = "armin.ronacher@active-4.com"}]8classifiers = [9 "Development Status :: 5 - Production/Stable",10 "Environment :: Web Environment",11 "Intended Audience :: Developers",12 "License :: OSI Approved :: BSD License",13 "Operating System :: OS Independent",14 "Programming Language :: Python",15 "Topic :: Internet :: WWW/HTTP :: Dynamic Content",16 "Topic :: Text Processing :: Markup :: HTML",17]18requires-python = ">=3.7"19dependencies = ["MarkupSafe>=2.0"]20dynamic = ["version"]2122[project.urls]23Donate = "https://palletsprojects.com/donate"24Documentation = "https://jinja.palletsprojects.com/"25Changes = "https://jinja.palletsprojects.com/changes/"26"Source Code" = "https://github.com/pallets/jinja/"27"Issue Tracker" = "https://github.com/pallets/jinja/issues/"28Twitter = "https://twitter.com/PalletsTeam"29Chat = "https://discord.gg/pallets"3031[project.optional-dependencies]32i18n = ["Babel>=2.7"]3334[project.entry-points."babel.extractors"]3536[build-system]37requires = ["setuptools"]38build-backend = "setuptools.build_meta"3940[tool.setuptools.dynamic]41version = {attr = "jinja2.__version__"}4243[tool.pytest.ini_options]44testpaths = ["tests"]45filterwarnings = ["error"]4647[tool.coverage.run]48branch = true49source = ["jinja2", "tests"]5051[tool.coverage.paths]52source = ["src", "*/site-packages"]5354[tool.mypy]55python_version = "3.7"56files = ["src/jinja2"]57show_error_codes = true58pretty = true59strict = true60local_partial_types = true61warn_unreachable = true6263[[tool.mypy.overrides]]64module = [65 "jinja2.defaults",66 "markupsafe",67]68no_implicit_reexport = false
deleted:setup.cfg-111 removed
1[metadata]2name = Jinja23version = attr: jinja2.__version__4url = https://palletsprojects.com/p/jinja/5project_urls =6 Donate = https://palletsprojects.com/donate7 Documentation = https://jinja.palletsprojects.com/8 Changes = https://jinja.palletsprojects.com/changes/9 Source Code = https://github.com/pallets/jinja/10 Issue Tracker = https://github.com/pallets/jinja/issues/11 Twitter = https://twitter.com/PalletsTeam12 Chat = https://discord.gg/pallets13license = BSD-3-Clause14license_files = LICENSE.rst15author = Armin Ronacher16author_email = armin.ronacher@active-4.com17maintainer = Pallets18maintainer_email = contact@palletsprojects.com19description = A very fast and expressive template engine.20long_description = file: README.rst21long_description_content_type = text/x-rst22classifiers =23 Development Status :: 5 - Production/Stable24 Environment :: Web Environment25 Intended Audience :: Developers26 License :: OSI Approved :: BSD License27 Operating System :: OS Independent28 Programming Language :: Python29 Topic :: Internet :: WWW/HTTP :: Dynamic Content30 Topic :: Text Processing :: Markup :: HTML3132[options]33packages = find:34package_dir = = src35include_package_data = True36python_requires = >= 3.737# Dependencies are in setup.py for GitHub's dependency graph.3839[options.packages.find]40where = src4142[options.entry_points]43babel.extractors =44 jinja2 = jinja2.ext:babel_extract[i18n]4546[tool:pytest]47testpaths = tests48filterwarnings =49 error50 # Python 3.9 raises a deprecation from internal asyncio code.51 ignore:The loop argument:DeprecationWarning:asyncio[.]base_events:5425253[coverage:run]54branch = True55source =56 jinja257 tests5859[coverage:paths]60source =61 src62 */site-packages6364[flake8]65# B = bugbear66# E = pycodestyle errors67# F = flake8 pyflakes68# W = pycodestyle warnings69# B9 = bugbear opinions70# ISC = implicit str concat71select = B, E, F, W, B9, ISC72ignore =73 # slice notation whitespace, invalid74 E20375 # line length, handled by bugbear B95076 E50177 # bare except, handled by bugbear B00178 E72279 # bin op line break, invalid80 W50381 # zip with strict=, requires python >= 3.1082 B90583# up to 88 allowed by bugbear B95084max-line-length = 8085per-file-ignores =86 # __init__ exports names87 src/jinja2/__init__.py: F4018889[mypy]90files = src/jinja291python_version = 3.792show_error_codes = True93disallow_subclassing_any = True94disallow_untyped_calls = True95disallow_untyped_defs = True96disallow_incomplete_defs = True97no_implicit_optional = True98local_partial_types = True99no_implicit_reexport = True100strict_equality = True101warn_redundant_casts = True102warn_unused_configs = True103warn_unused_ignores = True104warn_return_any = True105warn_unreachable = True106107[mypy-jinja2.defaults]108no_implicit_reexport = False109110[mypy-markupsafe]111no_implicit_reexport = False
deleted:setup.py-8 removed
1from setuptools import setup23# Metadata goes in setup.cfg. These are here for GitHub's dependency graph.4setup(5 name="Jinja2",6 install_requires=["MarkupSafe>=2.0"],7 extras_require={"i18n": ["Babel>=2.7"]},8)