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
Provenance
- Commit
05a5f81- Tree
842087b- Author
David Lord <davidism@gmail.com>- Committer
GitHub <noreply@github.com>- Parent 1
048a068- Parent 2
8ed8e1d
17 files changed+161 added−158 removed
modified:.github/workflows/tests.yaml+1 added-1 removed
48 unmodified lines49505152535354555648 unmodified lines - name: cache mypy uses: actions/cache@v3 with: path: ./.mypy_cache key: mypy|${{ matrix.python }}|${{ hashFiles('setup.cfg') }} key: mypy|${{ matrix.python }}|${{ hashFiles('pyproject.toml') }} if: matrix.tox == 'typing' - run: pip install tox - run: tox run -e ${{ matrix.tox }}modified:src/jinja2/async_utils.py+1 added-1 removed
45 unmodified lines46 47 if need_eval_context:48 wrapper = pass_eval_context(wrapper)49 50- wrapper.jinja_async_variant = True50+ wrapper.jinja_async_variant = True # type: ignore[attr-defined]51 return wrapper52 53 return decorator54 30 unmodified linesmodified:src/jinja2/environment.py+7 added-5 removed
77 unmodified lines78 79 80 def 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 lines90 return LRUCache(size) # type: ignore91 92 93 def 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 lines815 return TemplateExpression(template, undefined_to_none)816 817 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 lines1589 self.disable_buffering()1590 1591 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 linesmodified:src/jinja2/filters.py+23 added-19 removed
536 unmodified lines537 538 @pass_eval_context539 def 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 the49 unmodified lines595 596 @async_variant(sync_do_join) # type: ignore597 async 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 lines1145 1146 1147 class _GroupTuple(t.NamedTuple):1148 grouper: t.Any1149- list: t.List1149+ list: t.List[t.Any]1150 1151 # Use the regular tuple repr to hide this subclass if users print1152 # out the value during debugging.1153 def __repr__(self) -> str:247 unmodified lines1401 1402 1403 @typing.overload1404 def 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 ...1412 1413 1414 @typing.overload1415 def 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 ...1423 1424 1425 @pass_context1426 def 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 lines1474 1475 @typing.overload1476 def 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 ...1484 1485 1486 @typing.overload1487 def 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 ...1495 1496 1497 @async_variant(sync_do_map) # type: ignore1498 async 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)1506 1507 async for item in auto_aiter(value):184 unmodified lines1692 return htmlsafe_json_dumps(value, dumps=dumps, **kwargs)1693 1694 1695 def 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 lines1721 1722 1723 def 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 lines1756 1757 def 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 lines1772 1773 async 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 linesmodified:src/jinja2/lexer.py+1 added-1 removed
445 unmodified lines446 447 return lexer448 449 450-class OptionalLStrip(tuple):450+class 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 linesmodified:src/jinja2/loaders.py+7 added-2 removed
175 unmodified lines176 """177 178 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 lines599 600 has_source_access = False601 602 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}"609 610 # create a fake module that looks for the templates in the53 unmodified linesmodified:src/jinja2/nodes.py+1 added-1 removed
54 unmodified lines55 automatically forwarded to the child."""56 57 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 linesmodified:src/jinja2/parser.py+9 added-2 removed
857 unmodified lines858 args.append(None)859 860 return nodes.Slice(lineno=lineno, *args)861 862- 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 = None82 unmodified lines956 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 linesmodified:src/jinja2/runtime.py+4 added-1 removed
257 unmodified lines258 return dict(self.parent, **self.vars)259 260 @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` or787 unmodified linesmodified:src/jinja2/sandbox.py+3 added-3 removed
35 unmodified lines36 37 #: unsafe attributes on async generators38 UNSAFE_ASYNC_GENERATOR_ATTRIBUTES = {"ag_code", "ag_frame"}39 40-_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 lines79 ),80 )81 82 83-def inspect_format_method(callable: t.Callable) -> t.Optional[str]:83+def 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 None261 unmodified lines349 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 linesmodified:src/jinja2/tests.py+1 added-1 removed
202 unmodified lines203 """Check if the value is escaped."""204 return hasattr(value, "__html__")205 206 207-def test_in(value: t.Any, seq: t.Container) -> bool:207+def test_in(value: t.Any, seq: t.Container[t.Any]) -> bool:208 """Check if value is in seq.209 210 .. versionadded:: 2.10211 """44 unmodified linesmodified:src/jinja2/utils.py+4 added-2 removed
150 unmodified lines151 if not silent:152 raise153 154 155-def open_if_exists(filename: str, mode: str = "rb") -> t.Optional[t.IO]:155+def 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 lines449 def __setstate__(self, d: t.Mapping[str, t.Any]) -> None:450 self.__dict__.update(d)451 self._postinit()452 453- def __getnewargs__(self) -> t.Tuple:453+ def __getnewargs__(454+ self,455+ ) -> t.Tuple[int,]:456 return (self.capacity,)457 458 def copy(self) -> "LRUCache":459 """Return a shallow copy of the instance."""298 unmodified linesadded:.flake8+28 added
1+[flake8]2+extend-select =3+ # bugbear4+ B5+ # bugbear opinions6+ B97+ # implicit str concat8+ ISC9+extend-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 B95022+max-line-length = 8023+per-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: B906modified:CHANGES.rst+3 added
3 unmodified lines4 -------------5 6 Unreleased7 8+- Use modern packaging metadata with ``pyproject.toml`` instead of ``setup.cfg``.9+ :pr:`1793`10 11+12 Version 3.1.213 -------------14 15 Released 2022-04-28969 unmodified linesadded:pyproject.toml+68 added
1+[project]2+name = "Jinja2"3+description = "A very fast and expressive template engine."4+readme = "README.rst"5+license = {text = "BSD-3-Clause"}6+maintainers = [{name = "Pallets", email = "contact@palletsprojects.com"}]7+authors = [{name = "Armin Ronacher", email = "armin.ronacher@active-4.com"}]8+classifiers = [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+]18+requires-python = ">=3.7"19+dependencies = ["MarkupSafe>=2.0"]20+dynamic = ["version"]21+22+[project.urls]23+Donate = "https://palletsprojects.com/donate"24+Documentation = "https://jinja.palletsprojects.com/"25+Changes = "https://jinja.palletsprojects.com/changes/"26+"Source Code" = "https://github.com/pallets/jinja/"27+"Issue Tracker" = "https://github.com/pallets/jinja/issues/"28+Twitter = "https://twitter.com/PalletsTeam"29+Chat = "https://discord.gg/pallets"30+31+[project.optional-dependencies]32+i18n = ["Babel>=2.7"]33+34+[project.entry-points."babel.extractors"]35+36+[build-system]37+requires = ["setuptools"]38+build-backend = "setuptools.build_meta"39+40+[tool.setuptools.dynamic]41+version = {attr = "jinja2.__version__"}42+43+[tool.pytest.ini_options]44+testpaths = ["tests"]45+filterwarnings = ["error"]46+47+[tool.coverage.run]48+branch = true49+source = ["jinja2", "tests"]50+51+[tool.coverage.paths]52+source = ["src", "*/site-packages"]53+54+[tool.mypy]55+python_version = "3.7"56+files = ["src/jinja2"]57+show_error_codes = true58+pretty = true59+strict = true60+local_partial_types = true61+warn_unreachable = true62+63+[[tool.mypy.overrides]]64+module = [65+ "jinja2.defaults",66+ "markupsafe",67+]68+no_implicit_reexport = falsedeleted:setup.cfg-111 removed
1-[metadata]2-name = Jinja23-version = attr: jinja2.__version__4-url = https://palletsprojects.com/p/jinja/5-project_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/pallets13-license = BSD-3-Clause14-license_files = LICENSE.rst15-author = Armin Ronacher16-author_email = armin.ronacher@active-4.com17-maintainer = Pallets18-maintainer_email = contact@palletsprojects.com19-description = A very fast and expressive template engine.20-long_description = file: README.rst21-long_description_content_type = text/x-rst22-classifiers =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 :: HTML31-32-[options]33-packages = find:34-package_dir = = src35-include_package_data = True36-python_requires = >= 3.737-# Dependencies are in setup.py for GitHub's dependency graph.38-39-[options.packages.find]40-where = src41-42-[options.entry_points]43-babel.extractors =44- jinja2 = jinja2.ext:babel_extract[i18n]45-46-[tool:pytest]47-testpaths = tests48-filterwarnings =49- error50- # Python 3.9 raises a deprecation from internal asyncio code.51- ignore:The loop argument:DeprecationWarning:asyncio[.]base_events:54252-53-[coverage:run]54-branch = True55-source =56- jinja257- tests58-59-[coverage:paths]60-source =61- src62- */site-packages63-64-[flake8]65-# B = bugbear66-# E = pycodestyle errors67-# F = flake8 pyflakes68-# W = pycodestyle warnings69-# B9 = bugbear opinions70-# ISC = implicit str concat71-select = B, E, F, W, B9, ISC72-ignore =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 B95084-max-line-length = 8085-per-file-ignores =86- # __init__ exports names87- src/jinja2/__init__.py: F40188-89-[mypy]90-files = src/jinja291-python_version = 3.792-show_error_codes = True93-disallow_subclassing_any = True94-disallow_untyped_calls = True95-disallow_untyped_defs = True96-disallow_incomplete_defs = True97-no_implicit_optional = True98-local_partial_types = True99-no_implicit_reexport = True100-strict_equality = True101-warn_redundant_casts = True102-warn_unused_configs = True103-warn_unused_ignores = True104-warn_return_any = True105-warn_unreachable = True106-107-[mypy-jinja2.defaults]108-no_implicit_reexport = False109-110-[mypy-markupsafe]111-no_implicit_reexport = Falsedeleted:setup.py-8 removed
1-from setuptools import setup2-3-# Metadata goes in setup.cfg. These are here for GitHub's dependency graph.4-setup(5- name="Jinja2",6- install_requires=["MarkupSafe>=2.0"],7- extras_require={"i18n": ["Babel>=2.7"]},8-)