From b7033aceae1ff31759f32b9158b1b880225fe23b Mon Sep 17 00:00:00 2001 From: Dominic Davis-Foster Date: Mon, 8 Apr 2024 14:34:27 +0100 Subject: [PATCH] Update for dom-toml v2 (#60) --- formate.toml | 1 - pyproject_parser/__init__.py | 169 ++++++++++++++++-- pyproject_parser/__main__.py | 2 +- pyproject_parser/utils.py | 10 +- requirements.txt | 4 +- tests/requirements.txt | 1 + .../test_reformat_False_COMPLETE_A_.toml | 1 - ...reformat_False_COMPLETE_A_WITH_FILES_.toml | 7 +- .../test_reformat_False_COMPLETE_B_.toml | 1 - ...st_reformat_False_COMPLETE_PROJECT_A_.toml | 9 +- ...ormat_False_COMPLETE_UNDERSCORE_NAME_.toml | 1 - .../test_reformat_False_UNORDERED_.toml | 1 - .../test_reformat_True_COMPLETE_A_.diff | 3 +- .../test_reformat_True_COMPLETE_A_.toml | 1 - ..._reformat_True_COMPLETE_A_WITH_FILES_.diff | 9 +- ..._reformat_True_COMPLETE_A_WITH_FILES_.toml | 7 +- .../test_reformat_True_COMPLETE_B_.diff | 5 +- .../test_reformat_True_COMPLETE_B_.toml | 1 - ...est_reformat_True_COMPLETE_PROJECT_A_.diff | 15 +- ...est_reformat_True_COMPLETE_PROJECT_A_.toml | 9 +- ...format_True_COMPLETE_UNDERSCORE_NAME_.diff | 3 +- ...format_True_COMPLETE_UNDERSCORE_NAME_.toml | 1 - .../test_reformat_True_UNORDERED_.diff | 8 +- .../test_reformat_True_UNORDERED_.toml | 1 - .../test_dumping_/test_dumps_COMPLETE_A_.toml | 1 - .../test_dumping_/test_dumps_COMPLETE_B_.toml | 1 - .../test_dumps_COMPLETE_PROJECT_A_.toml | 9 +- .../test_dumps_readme_dict_file_.toml | 5 +- .../test_dumps_readme_dict_text_.toml | 13 +- .../test_dumps_readme_string_.toml | 5 +- .../test_reformat_COMPLETE_A_.toml | 1 - .../test_reformat_COMPLETE_A_WITH_FILES_.toml | 7 +- .../test_reformat_COMPLETE_B_.toml | 1 - .../test_reformat_COMPLETE_PROJECT_A_.toml | 9 +- ...st_reformat_COMPLETE_UNDERSCORE_NAME_.toml | 1 - .../test_reformat_UNORDERED_.toml | 1 - 36 files changed, 209 insertions(+), 115 deletions(-) diff --git a/formate.toml b/formate.toml index 2ba41c9..10733f7 100644 --- a/formate.toml +++ b/formate.toml @@ -48,7 +48,6 @@ known_third_party = [ "pytest_randomly", "pytest_timeout", "shippinglabel", - "toml", "tomli", "typing_extensions", ] diff --git a/pyproject_parser/__init__.py b/pyproject_parser/__init__.py index 770e53d..f5c9bbf 100644 --- a/pyproject_parser/__init__.py +++ b/pyproject_parser/__init__.py @@ -7,6 +7,10 @@ # # Copyright © 2021 Dominic Davis-Foster # +# PyProjectTomlEncoder.dumps based on https://github.com/hukkin/tomli-w +# MIT Licensed +# Copyright (c) 2021 Taneli Hukkinen +# # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights @@ -27,13 +31,26 @@ # # stdlib -from typing import Any, ClassVar, Dict, Mapping, MutableMapping, Optional, Type, TypeVar, Union +from typing import ( + Any, + ClassVar, + Dict, + Iterator, + List, + Mapping, + MutableMapping, + Optional, + Tuple, + Type, + TypeVar, + Union + ) # 3rd party import attr import dom_toml -import toml -from dom_toml.encoder import _dump_str +from dom_toml.decoder import InlineTableDict +from dom_toml.encoder import TomlEncoder from dom_toml.parser import AbstractConfigParser, BadConfigError from domdf_python_tools.paths import PathPlus, in_directory from domdf_python_tools.typing import PathLike @@ -66,6 +83,29 @@ _PP = TypeVar("_PP", bound="PyProject") +_translation_table = { + 8: "\\b", + 9: "\\t", + 10: "\\n", + 12: "\\f", + 13: "\\r", + 92: "\\\\", + } + + +def _dump_str(v: str) -> str: + v = str(v).translate(_translation_table) + + if "'" in v and '"' not in v: + quote_char = '"' + elif '"' in v and "'" not in v: + quote_char = "'" + else: + quote_char = '"' + v = v.replace('"', '\\"') + + return f"{quote_char}{v}{quote_char}" + class PyProjectTomlEncoder(dom_toml.TomlEncoder): """ @@ -76,14 +116,108 @@ class PyProjectTomlEncoder(dom_toml.TomlEncoder): .. autosummary-widths:: 23/64 """ - def __init__(self, _dict=dict, preserve: bool = False) -> None: # noqa: MAN001 - super().__init__(_dict=_dict, preserve=preserve) - self.dump_funcs[str] = _dump_str - self.dump_funcs[_NormalisedName] = _dump_str - self.dump_funcs[Version] = self.dump_packaging_types - self.dump_funcs[Requirement] = self.dump_packaging_types - self.dump_funcs[Marker] = self.dump_packaging_types - self.dump_funcs[SpecifierSet] = self.dump_packaging_types + def __init__(self, preserve: bool = False) -> None: + super().__init__(preserve=preserve) + + def dumps( + self, + table: Mapping[str, Any], + *, + name: str, + inside_aot: bool = False, + ) -> Iterator[str]: + """ + Serialise the given table. + + :param name: The table name. + :param inside_aot: + + :rtype: + + .. versionadded:: 0.11.0 + """ + + yielded = False + literals = [] + tables: List[Tuple[str, Any, bool]] = [] + for k, v in table.items(): + if v is None: + continue + if self.preserve and isinstance(v, InlineTableDict): + literals.append((k, v)) + elif isinstance(v, dict): + tables.append((k, v, False)) + elif self._is_aot(v): + tables.extend((k, t, True) for t in v) + else: + literals.append((k, v)) + + if inside_aot or name and (literals or not tables): + yielded = True + yield f"[[{name}]]\n" if inside_aot else f"[{name}]\n" + + if literals: + yielded = True + for k, v in literals: + yield f"{self.format_key_part(k)} = {self.format_literal(v)}\n" + + for k, v, in_aot in tables: + if yielded: + yield '\n' + else: + yielded = True + key_part = self.format_key_part(k) + display_name = f"{name}.{key_part}" if name else key_part + + yield from self.dumps(v, name=display_name, inside_aot=in_aot) + + def format_literal(self, obj: object, *, nest_level: int = 0) -> str: + """ + Format a literal value. + + :param obj: + :param nest_level: + + :rtype: + + .. versionadded:: 0.11.0 + """ + + if isinstance(obj, (str, _NormalisedName)): + return _dump_str(obj) + elif isinstance(obj, (Version, Requirement, Marker, SpecifierSet)): + return self.dump_packaging_types(obj) + else: + return super().format_literal(obj, nest_level=nest_level) + + def format_inline_array(self, obj: Union[Tuple, List], nest_level: int) -> str: + """ + Format an inline array. + + :param obj: + :param nest_level: + + :rtype: + + .. versionadded:: 0.11.0 + """ + + if not len(obj): + return "[]" + + item_indent = " " * (1 + nest_level) + closing_bracket_indent = " " * nest_level + single_line = "[ " + ", ".join( + self.format_literal(item, nest_level=nest_level + 1) for item in obj + ) + f",]" + + if len(single_line) <= self.max_width: + return single_line + else: + start = "[\n" + body = ",\n".join(item_indent + self.format_literal(item, nest_level=nest_level + 1) for item in obj) + end = f",\n{closing_bracket_indent}]" + return start + body + end @staticmethod def dump_packaging_types(obj: Union[Version, Requirement, Marker, SpecifierSet]) -> str: @@ -227,12 +361,12 @@ def load( def dumps( self, - encoder: Union[Type[toml.TomlEncoder], toml.TomlEncoder] = PyProjectTomlEncoder, + encoder: Union[Type[TomlEncoder], TomlEncoder] = PyProjectTomlEncoder, ) -> str: """ Serialise to TOML. - :param encoder: The :class:`toml.TomlEncoder` to use for constructing the output string. + :param encoder: The :class:`~dom_toml.encoder.TomlEncoder` to use for constructing the output string. """ # TODO: filter out default values (lists and dicts) @@ -250,7 +384,6 @@ def dumps( "license": toml_dict["project"]["license"].to_pep621_dict() } - if toml_dict["project"] is not None: if "readme" in toml_dict["project"] and toml_dict["project"]["readme"] is not None: readme_dict = toml_dict["project"]["readme"].to_pep621_dict() @@ -268,13 +401,13 @@ def dumps( def dump( self, filename: PathLike, - encoder: Union[Type[toml.TomlEncoder], toml.TomlEncoder] = PyProjectTomlEncoder, + encoder: Union[Type[TomlEncoder], TomlEncoder] = PyProjectTomlEncoder, ) -> str: """ Write as TOML to the given file. :param filename: The filename to write to. - :param encoder: The :class:`toml.TomlEncoder` to use for constructing the output string. + :param encoder: The :class:`~dom_toml.encoder.TomlEncoder` to use for constructing the output string. :returns: A string containing the TOML representation. """ @@ -288,13 +421,13 @@ def dump( def reformat( cls: Type[_PP], filename: PathLike, - encoder: Union[Type[toml.TomlEncoder], toml.TomlEncoder] = PyProjectTomlEncoder, + encoder: Union[Type[TomlEncoder], TomlEncoder] = PyProjectTomlEncoder, ) -> str: """ Reformat the given ``pyproject.toml`` file. :param filename: The file to reformat. - :param encoder: The :class:`toml.TomlEncoder` to use for constructing the output string. + :param encoder: The :class:`~dom_toml.encoder.TomlEncoder` to use for constructing the output string. :returns: A string containing the reformatted TOML. diff --git a/pyproject_parser/__main__.py b/pyproject_parser/__main__.py index 3c36e94..b836495 100644 --- a/pyproject_parser/__main__.py +++ b/pyproject_parser/__main__.py @@ -52,8 +52,8 @@ if TYPE_CHECKING: # 3rd party from consolekit.terminal_colours import ColourTrilean + from dom_toml.encoder import TomlEncoder from domdf_python_tools.typing import PathLike - from toml import TomlEncoder __all__ = ["main", "reformat", "check"] diff --git a/pyproject_parser/utils.py b/pyproject_parser/utils.py index 5864a68..fdd3867 100644 --- a/pyproject_parser/utils.py +++ b/pyproject_parser/utils.py @@ -34,17 +34,11 @@ from typing import TYPE_CHECKING, Any, Dict, Optional # 3rd party +import dom_toml from dom_toml.parser import BadConfigError from domdf_python_tools.paths import PathPlus from domdf_python_tools.typing import PathLike -if sys.version_info < (3, 11): - # 3rd party - import tomli as tomllib -else: - # stdlib - import tomllib - if TYPE_CHECKING: # this package from pyproject_parser.type_hints import ContentTypes @@ -192,4 +186,4 @@ def _load_toml(filename: PathLike, ) -> Dict[str, Any]: :returns: A mapping containing the ``TOML`` data. """ - return tomllib.loads(PathPlus(filename).read_text()) + return dom_toml.load(filename) diff --git a/requirements.txt b/requirements.txt index c35b2e5..51c4eab 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,8 @@ apeye-core>=1.0.0 attrs>=20.3.0 -dom-toml>=0.4.0 +dom-toml>=2.0.0b1 domdf-python-tools>=2.8.0 natsort>=7.1.1 packaging>=20.9 shippinglabel>=1.0.0 -toml>=0.10.2 -tomli>=1.2.3; python_version < "3.11" typing-extensions!=4.7.0,>=3.7.4.3 diff --git a/tests/requirements.txt b/tests/requirements.txt index a921c6b..848c90e 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,4 +1,5 @@ # git+https://github.com/repo-helper/pyproject-examples +git+https://github.com/domdfcoding/dom_toml@v2 coincidence>=0.2.0 coverage>=5.1 coverage-pyver-pragma>=0.2.1 diff --git a/tests/test_cli_/test_reformat_False_COMPLETE_A_.toml b/tests/test_cli_/test_reformat_False_COMPLETE_A_.toml index 7e96650..87a5f39 100644 --- a/tests/test_cli_/test_reformat_False_COMPLETE_A_.toml +++ b/tests/test_cli_/test_reformat_False_COMPLETE_A_.toml @@ -14,7 +14,6 @@ dynamic = [ "classifiers", "requires-python",] name = "Dominic Davis-Foster" email = "dominic@davis-foster.co.uk" - [project.urls] Homepage = "https://whey.readthedocs.io/en/latest" Documentation = "https://whey.readthedocs.io/en/latest" diff --git a/tests/test_cli_/test_reformat_False_COMPLETE_A_WITH_FILES_.toml b/tests/test_cli_/test_reformat_False_COMPLETE_A_WITH_FILES_.toml index 451ad57..cb5e581 100644 --- a/tests/test_cli_/test_reformat_False_COMPLETE_A_WITH_FILES_.toml +++ b/tests/test_cli_/test_reformat_False_COMPLETE_A_WITH_FILES_.toml @@ -11,14 +11,13 @@ keywords = [ "build", "distribution", "packaging", "pep517", "pep621", "sdist", dependencies = [ 'django>2.1; os_name != "nt"', 'django>2.0; os_name == "nt"', "gidgethub[httpx]>4.0.0", "httpx",] dynamic = [ "classifiers", "requires-python",] +[project.license] +file = "LICENSE" + [[project.authors]] name = "Dominic Davis-Foster" email = "dominic@davis-foster.co.uk" - -[project.license] -file = "LICENSE" - [project.urls] Homepage = "https://whey.readthedocs.io/en/latest" Documentation = "https://whey.readthedocs.io/en/latest" diff --git a/tests/test_cli_/test_reformat_False_COMPLETE_B_.toml b/tests/test_cli_/test_reformat_False_COMPLETE_B_.toml index 94ca1ef..df38cce 100644 --- a/tests/test_cli_/test_reformat_False_COMPLETE_B_.toml +++ b/tests/test_cli_/test_reformat_False_COMPLETE_B_.toml @@ -14,7 +14,6 @@ dynamic = [ "classifiers", "requires-python",] name = "Dominic Davis-Foster" email = "dominic@davis-foster.co.uk" - [project.urls] Homepage = "https://whey.readthedocs.io/en/latest" Documentation = "https://whey.readthedocs.io/en/latest" diff --git a/tests/test_cli_/test_reformat_False_COMPLETE_PROJECT_A_.toml b/tests/test_cli_/test_reformat_False_COMPLETE_PROJECT_A_.toml index 4241b50..1ee6b1f 100644 --- a/tests/test_cli_/test_reformat_False_COMPLETE_PROJECT_A_.toml +++ b/tests/test_cli_/test_reformat_False_COMPLETE_PROJECT_A_.toml @@ -18,9 +18,6 @@ name = "Tzu-Ping Chung" name = "Brett Cannon" email = "brett@python.org" - -[tool] - [project.urls] homepage = "example.com" documentation = "readthedocs.org" @@ -33,8 +30,10 @@ spam-cli = "spam:main_cli" [project.gui-scripts] spam-gui = "spam:main_gui" +[project.entry-points."spam.magical"] +tomatoes = "spam:main_tomatoes" + [project.optional-dependencies] test = [ "pytest<5.0.0", "pytest-cov[all]",] -[project.entry-points."spam.magical"] -tomatoes = "spam:main_tomatoes" +[tool] diff --git a/tests/test_cli_/test_reformat_False_COMPLETE_UNDERSCORE_NAME_.toml b/tests/test_cli_/test_reformat_False_COMPLETE_UNDERSCORE_NAME_.toml index 8800610..2fc1d35 100644 --- a/tests/test_cli_/test_reformat_False_COMPLETE_UNDERSCORE_NAME_.toml +++ b/tests/test_cli_/test_reformat_False_COMPLETE_UNDERSCORE_NAME_.toml @@ -14,7 +14,6 @@ dynamic = [ "classifiers", "requires-python",] name = "Dominic Davis-Foster" email = "dominic@davis-foster.co.uk" - [project.urls] Homepage = "https://whey.readthedocs.io/en/latest" Documentation = "https://whey.readthedocs.io/en/latest" diff --git a/tests/test_cli_/test_reformat_False_UNORDERED_.toml b/tests/test_cli_/test_reformat_False_UNORDERED_.toml index 7e96650..87a5f39 100644 --- a/tests/test_cli_/test_reformat_False_UNORDERED_.toml +++ b/tests/test_cli_/test_reformat_False_UNORDERED_.toml @@ -14,7 +14,6 @@ dynamic = [ "classifiers", "requires-python",] name = "Dominic Davis-Foster" email = "dominic@davis-foster.co.uk" - [project.urls] Homepage = "https://whey.readthedocs.io/en/latest" Documentation = "https://whey.readthedocs.io/en/latest" diff --git a/tests/test_cli_/test_reformat_True_COMPLETE_A_.diff b/tests/test_cli_/test_reformat_True_COMPLETE_A_.diff index f018d28..e938431 100644 --- a/tests/test_cli_/test_reformat_True_COMPLETE_A_.diff +++ b/tests/test_cli_/test_reformat_True_COMPLETE_A_.diff @@ -1,7 +1,7 @@ Reformatting 'pyproject.toml' --- pyproject.toml (original) +++ pyproject.toml (reformatted) -@@ -6,18 +6,14 @@ +@@ -6,18 +6,13 @@ name = "whey" version = "2021.0.0" description = "A simple Python wheel builder for simple projects." @@ -20,7 +20,6 @@ Reformatting 'pyproject.toml' +name = "Dominic Davis-Foster" email = "dominic@davis-foster.co.uk" -name = "Dominic Davis-Foster" -+ [project.urls] Homepage = "https://whey.readthedocs.io/en/latest" diff --git a/tests/test_cli_/test_reformat_True_COMPLETE_A_.toml b/tests/test_cli_/test_reformat_True_COMPLETE_A_.toml index 7e96650..87a5f39 100644 --- a/tests/test_cli_/test_reformat_True_COMPLETE_A_.toml +++ b/tests/test_cli_/test_reformat_True_COMPLETE_A_.toml @@ -14,7 +14,6 @@ dynamic = [ "classifiers", "requires-python",] name = "Dominic Davis-Foster" email = "dominic@davis-foster.co.uk" - [project.urls] Homepage = "https://whey.readthedocs.io/en/latest" Documentation = "https://whey.readthedocs.io/en/latest" diff --git a/tests/test_cli_/test_reformat_True_COMPLETE_A_WITH_FILES_.diff b/tests/test_cli_/test_reformat_True_COMPLETE_A_WITH_FILES_.diff index 81895ca..6f6bdf6 100644 --- a/tests/test_cli_/test_reformat_True_COMPLETE_A_WITH_FILES_.diff +++ b/tests/test_cli_/test_reformat_True_COMPLETE_A_WITH_FILES_.diff @@ -1,7 +1,7 @@ Reformatting 'pyproject.toml' --- pyproject.toml (original) +++ pyproject.toml (reformatted) -@@ -6,20 +6,18 @@ +@@ -6,20 +6,17 @@ name = "whey" version = "2021.0.0" description = "A simple Python wheel builder for simple projects." @@ -18,15 +18,14 @@ Reformatting 'pyproject.toml' -] -license = { file = "LICENSE" } -readme = "README.rst" ++ ++[project.license] ++file = "LICENSE" [[project.authors]] +name = "Dominic Davis-Foster" email = "dominic@davis-foster.co.uk" -name = "Dominic Davis-Foster" -+ -+ -+[project.license] -+file = "LICENSE" [project.urls] Homepage = "https://whey.readthedocs.io/en/latest" diff --git a/tests/test_cli_/test_reformat_True_COMPLETE_A_WITH_FILES_.toml b/tests/test_cli_/test_reformat_True_COMPLETE_A_WITH_FILES_.toml index 451ad57..cb5e581 100644 --- a/tests/test_cli_/test_reformat_True_COMPLETE_A_WITH_FILES_.toml +++ b/tests/test_cli_/test_reformat_True_COMPLETE_A_WITH_FILES_.toml @@ -11,14 +11,13 @@ keywords = [ "build", "distribution", "packaging", "pep517", "pep621", "sdist", dependencies = [ 'django>2.1; os_name != "nt"', 'django>2.0; os_name == "nt"', "gidgethub[httpx]>4.0.0", "httpx",] dynamic = [ "classifiers", "requires-python",] +[project.license] +file = "LICENSE" + [[project.authors]] name = "Dominic Davis-Foster" email = "dominic@davis-foster.co.uk" - -[project.license] -file = "LICENSE" - [project.urls] Homepage = "https://whey.readthedocs.io/en/latest" Documentation = "https://whey.readthedocs.io/en/latest" diff --git a/tests/test_cli_/test_reformat_True_COMPLETE_B_.diff b/tests/test_cli_/test_reformat_True_COMPLETE_B_.diff index 0e92750..9c948ae 100644 --- a/tests/test_cli_/test_reformat_True_COMPLETE_B_.diff +++ b/tests/test_cli_/test_reformat_True_COMPLETE_B_.diff @@ -1,7 +1,7 @@ Reformatting 'pyproject.toml' --- pyproject.toml (original) +++ pyproject.toml (reformatted) -@@ -6,18 +6,14 @@ +@@ -6,18 +6,13 @@ name = "Whey" version = "2021.0.0" description = "A simple Python wheel builder for simple projects." @@ -20,11 +20,10 @@ Reformatting 'pyproject.toml' +name = "Dominic Davis-Foster" email = "dominic@davis-foster.co.uk" -name = "Dominic Davis-Foster" -+ [project.urls] Homepage = "https://whey.readthedocs.io/en/latest" -@@ -32,7 +28,5 @@ +@@ -32,7 +27,5 @@ platforms = [ "Windows", "macOS", "Linux",] license-key = "MIT" package = "whey" diff --git a/tests/test_cli_/test_reformat_True_COMPLETE_B_.toml b/tests/test_cli_/test_reformat_True_COMPLETE_B_.toml index 94ca1ef..df38cce 100644 --- a/tests/test_cli_/test_reformat_True_COMPLETE_B_.toml +++ b/tests/test_cli_/test_reformat_True_COMPLETE_B_.toml @@ -14,7 +14,6 @@ dynamic = [ "classifiers", "requires-python",] name = "Dominic Davis-Foster" email = "dominic@davis-foster.co.uk" - [project.urls] Homepage = "https://whey.readthedocs.io/en/latest" Documentation = "https://whey.readthedocs.io/en/latest" diff --git a/tests/test_cli_/test_reformat_True_COMPLETE_PROJECT_A_.diff b/tests/test_cli_/test_reformat_True_COMPLETE_PROJECT_A_.diff index 4010eed..e268929 100644 --- a/tests/test_cli_/test_reformat_True_COMPLETE_PROJECT_A_.diff +++ b/tests/test_cli_/test_reformat_True_COMPLETE_PROJECT_A_.diff @@ -1,7 +1,7 @@ Reformatting 'pyproject.toml' --- pyproject.toml (original) +++ pyproject.toml (reformatted) -@@ -3,31 +3,23 @@ +@@ -3,31 +3,20 @@ version = "2020.0.0" description = "Lovely Spam! Wonderful Spam!" requires-python = ">=3.8" @@ -42,18 +42,15 @@ Reformatting 'pyproject.toml' +[[project.maintainers]] +name = "Brett Cannon" +email = "brett@python.org" -+ -+ -+[tool] [project.urls] homepage = "example.com" -@@ -41,6 +33,9 @@ - [project.gui-scripts] - spam-gui = "spam:main_gui" +@@ -44,3 +33,8 @@ + [project.entry-points."spam.magical"] + tomatoes = "spam:main_tomatoes" +[project.optional-dependencies] +test = [ "pytest<5.0.0", "pytest-cov[all]",] + - [project.entry-points."spam.magical"] - tomatoes = "spam:main_tomatoes" ++[tool] ++ diff --git a/tests/test_cli_/test_reformat_True_COMPLETE_PROJECT_A_.toml b/tests/test_cli_/test_reformat_True_COMPLETE_PROJECT_A_.toml index 4241b50..1ee6b1f 100644 --- a/tests/test_cli_/test_reformat_True_COMPLETE_PROJECT_A_.toml +++ b/tests/test_cli_/test_reformat_True_COMPLETE_PROJECT_A_.toml @@ -18,9 +18,6 @@ name = "Tzu-Ping Chung" name = "Brett Cannon" email = "brett@python.org" - -[tool] - [project.urls] homepage = "example.com" documentation = "readthedocs.org" @@ -33,8 +30,10 @@ spam-cli = "spam:main_cli" [project.gui-scripts] spam-gui = "spam:main_gui" +[project.entry-points."spam.magical"] +tomatoes = "spam:main_tomatoes" + [project.optional-dependencies] test = [ "pytest<5.0.0", "pytest-cov[all]",] -[project.entry-points."spam.magical"] -tomatoes = "spam:main_tomatoes" +[tool] diff --git a/tests/test_cli_/test_reformat_True_COMPLETE_UNDERSCORE_NAME_.diff b/tests/test_cli_/test_reformat_True_COMPLETE_UNDERSCORE_NAME_.diff index f2fd298..b9bd1e8 100644 --- a/tests/test_cli_/test_reformat_True_COMPLETE_UNDERSCORE_NAME_.diff +++ b/tests/test_cli_/test_reformat_True_COMPLETE_UNDERSCORE_NAME_.diff @@ -1,7 +1,7 @@ Reformatting 'pyproject.toml' --- pyproject.toml (original) +++ pyproject.toml (reformatted) -@@ -6,18 +6,14 @@ +@@ -6,18 +6,13 @@ name = "toctree_plus" version = "2021.0.0" description = "A simple Python wheel builder for simple projects." @@ -20,7 +20,6 @@ Reformatting 'pyproject.toml' +name = "Dominic Davis-Foster" email = "dominic@davis-foster.co.uk" -name = "Dominic Davis-Foster" -+ [project.urls] Homepage = "https://whey.readthedocs.io/en/latest" diff --git a/tests/test_cli_/test_reformat_True_COMPLETE_UNDERSCORE_NAME_.toml b/tests/test_cli_/test_reformat_True_COMPLETE_UNDERSCORE_NAME_.toml index 8800610..2fc1d35 100644 --- a/tests/test_cli_/test_reformat_True_COMPLETE_UNDERSCORE_NAME_.toml +++ b/tests/test_cli_/test_reformat_True_COMPLETE_UNDERSCORE_NAME_.toml @@ -14,7 +14,6 @@ dynamic = [ "classifiers", "requires-python",] name = "Dominic Davis-Foster" email = "dominic@davis-foster.co.uk" - [project.urls] Homepage = "https://whey.readthedocs.io/en/latest" Documentation = "https://whey.readthedocs.io/en/latest" diff --git a/tests/test_cli_/test_reformat_True_UNORDERED_.diff b/tests/test_cli_/test_reformat_True_UNORDERED_.diff index e2563ef..c0a39b0 100644 --- a/tests/test_cli_/test_reformat_True_UNORDERED_.diff +++ b/tests/test_cli_/test_reformat_True_UNORDERED_.diff @@ -1,7 +1,7 @@ Reformatting 'pyproject.toml' --- pyproject.toml (original) +++ pyproject.toml (reformatted) -@@ -1,22 +1,18 @@ +@@ -1,29 +1,25 @@ -[project] -keywords = [ "pep517", "pep621", "build", "sdist", "wheel", "packaging", "distribution",] -version = "2021.0.0" @@ -27,14 +27,14 @@ Reformatting 'pyproject.toml' +dependencies = [ 'django>2.1; os_name != "nt"', 'django>2.0; os_name == "nt"', "gidgethub[httpx]>4.0.0", "httpx",] +dynamic = [ "classifiers", "requires-python",] +- - +[[project.authors]] +name = "Dominic Davis-Foster" +email = "dominic@davis-foster.co.uk" - [project.urls] -@@ -24,6 +20,7 @@ + Homepage = "https://whey.readthedocs.io/en/latest" Documentation = "https://whey.readthedocs.io/en/latest" "Issue Tracker" = "https://github.com/repo-helper/whey/issues" "Source Code" = "https://github.com/repo-helper/whey" @@ -42,7 +42,7 @@ Reformatting 'pyproject.toml' [tool.whey] base-classifiers = [ "Development Status :: 4 - Beta",] python-versions = [ "3.6", "3.7", "3.8", "3.9", "3.10",] -@@ -31,7 +28,3 @@ +@@ -31,7 +27,3 @@ platforms = [ "Windows", "macOS", "Linux",] license-key = "MIT" diff --git a/tests/test_cli_/test_reformat_True_UNORDERED_.toml b/tests/test_cli_/test_reformat_True_UNORDERED_.toml index 7e96650..87a5f39 100644 --- a/tests/test_cli_/test_reformat_True_UNORDERED_.toml +++ b/tests/test_cli_/test_reformat_True_UNORDERED_.toml @@ -14,7 +14,6 @@ dynamic = [ "classifiers", "requires-python",] name = "Dominic Davis-Foster" email = "dominic@davis-foster.co.uk" - [project.urls] Homepage = "https://whey.readthedocs.io/en/latest" Documentation = "https://whey.readthedocs.io/en/latest" diff --git a/tests/test_dumping_/test_dumps_COMPLETE_A_.toml b/tests/test_dumping_/test_dumps_COMPLETE_A_.toml index 7e96650..87a5f39 100644 --- a/tests/test_dumping_/test_dumps_COMPLETE_A_.toml +++ b/tests/test_dumping_/test_dumps_COMPLETE_A_.toml @@ -14,7 +14,6 @@ dynamic = [ "classifiers", "requires-python",] name = "Dominic Davis-Foster" email = "dominic@davis-foster.co.uk" - [project.urls] Homepage = "https://whey.readthedocs.io/en/latest" Documentation = "https://whey.readthedocs.io/en/latest" diff --git a/tests/test_dumping_/test_dumps_COMPLETE_B_.toml b/tests/test_dumping_/test_dumps_COMPLETE_B_.toml index a7374bf..5aa0b51 100644 --- a/tests/test_dumping_/test_dumps_COMPLETE_B_.toml +++ b/tests/test_dumping_/test_dumps_COMPLETE_B_.toml @@ -14,7 +14,6 @@ dynamic = [ "classifiers", "requires-python",] name = "Dominic Davis-Foster" email = "dominic@davis-foster.co.uk" - [project.urls] Homepage = "https://whey.readthedocs.io/en/latest" Documentation = "https://whey.readthedocs.io/en/latest" diff --git a/tests/test_dumping_/test_dumps_COMPLETE_PROJECT_A_.toml b/tests/test_dumping_/test_dumps_COMPLETE_PROJECT_A_.toml index 4241b50..1ee6b1f 100644 --- a/tests/test_dumping_/test_dumps_COMPLETE_PROJECT_A_.toml +++ b/tests/test_dumping_/test_dumps_COMPLETE_PROJECT_A_.toml @@ -18,9 +18,6 @@ name = "Tzu-Ping Chung" name = "Brett Cannon" email = "brett@python.org" - -[tool] - [project.urls] homepage = "example.com" documentation = "readthedocs.org" @@ -33,8 +30,10 @@ spam-cli = "spam:main_cli" [project.gui-scripts] spam-gui = "spam:main_gui" +[project.entry-points."spam.magical"] +tomatoes = "spam:main_tomatoes" + [project.optional-dependencies] test = [ "pytest<5.0.0", "pytest-cov[all]",] -[project.entry-points."spam.magical"] -tomatoes = "spam:main_tomatoes" +[tool] diff --git a/tests/test_dumping_/test_dumps_readme_dict_file_.toml b/tests/test_dumping_/test_dumps_readme_dict_file_.toml index a751993..4928a12 100644 --- a/tests/test_dumping_/test_dumps_readme_dict_file_.toml +++ b/tests/test_dumping_/test_dumps_readme_dict_file_.toml @@ -15,11 +15,10 @@ dynamic = [ "classifiers", "requires-python",] name = "Dominic Davis-Foster" email = "dominic@davis-foster.co.uk" - -[tool] - [project.urls] Homepage = "https://whey.readthedocs.io/en/latest" Documentation = "https://whey.readthedocs.io/en/latest" "Issue Tracker" = "https://github.com/repo-helper/whey/issues" "Source Code" = "https://github.com/repo-helper/whey" + +[tool] diff --git a/tests/test_dumping_/test_dumps_readme_dict_text_.toml b/tests/test_dumping_/test_dumps_readme_dict_text_.toml index 8d4e613..ffddf51 100644 --- a/tests/test_dumping_/test_dumps_readme_dict_text_.toml +++ b/tests/test_dumping_/test_dumps_readme_dict_text_.toml @@ -10,19 +10,18 @@ keywords = [ "build", "distribution", "packaging", "pep517", "pep621", "sdist", dependencies = [ 'django>2.1; os_name != "nt"', 'django>2.0; os_name == "nt"', "gidgethub[httpx]>4.0.0", "httpx",] dynamic = [ "classifiers", "requires-python",] -[[project.authors]] -name = "Dominic Davis-Foster" -email = "dominic@davis-foster.co.uk" - - -[tool] - [project.readme] content-type = "text/x-rst" text = "This is the README" +[[project.authors]] +name = "Dominic Davis-Foster" +email = "dominic@davis-foster.co.uk" + [project.urls] Homepage = "https://whey.readthedocs.io/en/latest" Documentation = "https://whey.readthedocs.io/en/latest" "Issue Tracker" = "https://github.com/repo-helper/whey/issues" "Source Code" = "https://github.com/repo-helper/whey" + +[tool] diff --git a/tests/test_dumping_/test_dumps_readme_string_.toml b/tests/test_dumping_/test_dumps_readme_string_.toml index a751993..4928a12 100644 --- a/tests/test_dumping_/test_dumps_readme_string_.toml +++ b/tests/test_dumping_/test_dumps_readme_string_.toml @@ -15,11 +15,10 @@ dynamic = [ "classifiers", "requires-python",] name = "Dominic Davis-Foster" email = "dominic@davis-foster.co.uk" - -[tool] - [project.urls] Homepage = "https://whey.readthedocs.io/en/latest" Documentation = "https://whey.readthedocs.io/en/latest" "Issue Tracker" = "https://github.com/repo-helper/whey/issues" "Source Code" = "https://github.com/repo-helper/whey" + +[tool] diff --git a/tests/test_dumping_/test_reformat_COMPLETE_A_.toml b/tests/test_dumping_/test_reformat_COMPLETE_A_.toml index 7e96650..87a5f39 100644 --- a/tests/test_dumping_/test_reformat_COMPLETE_A_.toml +++ b/tests/test_dumping_/test_reformat_COMPLETE_A_.toml @@ -14,7 +14,6 @@ dynamic = [ "classifiers", "requires-python",] name = "Dominic Davis-Foster" email = "dominic@davis-foster.co.uk" - [project.urls] Homepage = "https://whey.readthedocs.io/en/latest" Documentation = "https://whey.readthedocs.io/en/latest" diff --git a/tests/test_dumping_/test_reformat_COMPLETE_A_WITH_FILES_.toml b/tests/test_dumping_/test_reformat_COMPLETE_A_WITH_FILES_.toml index 451ad57..cb5e581 100644 --- a/tests/test_dumping_/test_reformat_COMPLETE_A_WITH_FILES_.toml +++ b/tests/test_dumping_/test_reformat_COMPLETE_A_WITH_FILES_.toml @@ -11,14 +11,13 @@ keywords = [ "build", "distribution", "packaging", "pep517", "pep621", "sdist", dependencies = [ 'django>2.1; os_name != "nt"', 'django>2.0; os_name == "nt"', "gidgethub[httpx]>4.0.0", "httpx",] dynamic = [ "classifiers", "requires-python",] +[project.license] +file = "LICENSE" + [[project.authors]] name = "Dominic Davis-Foster" email = "dominic@davis-foster.co.uk" - -[project.license] -file = "LICENSE" - [project.urls] Homepage = "https://whey.readthedocs.io/en/latest" Documentation = "https://whey.readthedocs.io/en/latest" diff --git a/tests/test_dumping_/test_reformat_COMPLETE_B_.toml b/tests/test_dumping_/test_reformat_COMPLETE_B_.toml index 94ca1ef..df38cce 100644 --- a/tests/test_dumping_/test_reformat_COMPLETE_B_.toml +++ b/tests/test_dumping_/test_reformat_COMPLETE_B_.toml @@ -14,7 +14,6 @@ dynamic = [ "classifiers", "requires-python",] name = "Dominic Davis-Foster" email = "dominic@davis-foster.co.uk" - [project.urls] Homepage = "https://whey.readthedocs.io/en/latest" Documentation = "https://whey.readthedocs.io/en/latest" diff --git a/tests/test_dumping_/test_reformat_COMPLETE_PROJECT_A_.toml b/tests/test_dumping_/test_reformat_COMPLETE_PROJECT_A_.toml index 4241b50..1ee6b1f 100644 --- a/tests/test_dumping_/test_reformat_COMPLETE_PROJECT_A_.toml +++ b/tests/test_dumping_/test_reformat_COMPLETE_PROJECT_A_.toml @@ -18,9 +18,6 @@ name = "Tzu-Ping Chung" name = "Brett Cannon" email = "brett@python.org" - -[tool] - [project.urls] homepage = "example.com" documentation = "readthedocs.org" @@ -33,8 +30,10 @@ spam-cli = "spam:main_cli" [project.gui-scripts] spam-gui = "spam:main_gui" +[project.entry-points."spam.magical"] +tomatoes = "spam:main_tomatoes" + [project.optional-dependencies] test = [ "pytest<5.0.0", "pytest-cov[all]",] -[project.entry-points."spam.magical"] -tomatoes = "spam:main_tomatoes" +[tool] diff --git a/tests/test_dumping_/test_reformat_COMPLETE_UNDERSCORE_NAME_.toml b/tests/test_dumping_/test_reformat_COMPLETE_UNDERSCORE_NAME_.toml index 8800610..2fc1d35 100644 --- a/tests/test_dumping_/test_reformat_COMPLETE_UNDERSCORE_NAME_.toml +++ b/tests/test_dumping_/test_reformat_COMPLETE_UNDERSCORE_NAME_.toml @@ -14,7 +14,6 @@ dynamic = [ "classifiers", "requires-python",] name = "Dominic Davis-Foster" email = "dominic@davis-foster.co.uk" - [project.urls] Homepage = "https://whey.readthedocs.io/en/latest" Documentation = "https://whey.readthedocs.io/en/latest" diff --git a/tests/test_dumping_/test_reformat_UNORDERED_.toml b/tests/test_dumping_/test_reformat_UNORDERED_.toml index 7e96650..87a5f39 100644 --- a/tests/test_dumping_/test_reformat_UNORDERED_.toml +++ b/tests/test_dumping_/test_reformat_UNORDERED_.toml @@ -14,7 +14,6 @@ dynamic = [ "classifiers", "requires-python",] name = "Dominic Davis-Foster" email = "dominic@davis-foster.co.uk" - [project.urls] Homepage = "https://whey.readthedocs.io/en/latest" Documentation = "https://whey.readthedocs.io/en/latest"