Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-poetry-dynamic-versioning for openSUSE:Factory checked in at 2024-09-11 16:55:52 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-poetry-dynamic-versioning (Old) and /work/SRC/openSUSE:Factory/.python-poetry-dynamic-versioning.new.17570 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-poetry-dynamic-versioning" Wed Sep 11 16:55:52 2024 rev:5 rq:1199947 version:1.4.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-poetry-dynamic-versioning/python-poetry-dynamic-versioning.changes 2024-07-01 11:22:22.567442398 +0200 +++ /work/SRC/openSUSE:Factory/.python-poetry-dynamic-versioning.new.17570/python-poetry-dynamic-versioning.changes 2024-09-11 16:56:37.265109728 +0200 @@ -1,0 +2,6 @@ +Wed Sep 11 05:43:07 UTC 2024 - Richard Rahl <rra...@opensuse.org> + +- update to 1.4.1: + * The enable command would fail when the pyproject.toml tables were out of order. + +------------------------------------------------------------------- Old: ---- poetry_dynamic_versioning-1.4.0.tar.gz New: ---- poetry_dynamic_versioning-1.4.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-poetry-dynamic-versioning.spec ++++++ --- /var/tmp/diff_new_pack.iBgrqr/_old 2024-09-11 16:56:41.185273480 +0200 +++ /var/tmp/diff_new_pack.iBgrqr/_new 2024-09-11 16:56:41.185273480 +0200 @@ -18,7 +18,7 @@ %{?sle15_python_module_pythons} Name: python-poetry-dynamic-versioning -Version: 1.4.0 +Version: 1.4.1 Release: 0 Summary: Plugin for Poetry to enable dynamic versioning based on VCS tags License: MIT ++++++ poetry_dynamic_versioning-1.4.0.tar.gz -> poetry_dynamic_versioning-1.4.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/poetry_dynamic_versioning-1.4.0/CHANGELOG.md new/poetry_dynamic_versioning-1.4.1/CHANGELOG.md --- old/poetry_dynamic_versioning-1.4.0/CHANGELOG.md 2024-06-17 23:51:59.444518600 +0200 +++ new/poetry_dynamic_versioning-1.4.1/CHANGELOG.md 2024-09-11 01:00:28.702265700 +0200 @@ -1,3 +1,8 @@ +## v1.4.1 (2024-09-10) + +* Fixed: + * The `enable` command would fail when the pyproject.toml tables were out of order. + ## v1.4.0 (2024-06-17) * Added: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/poetry_dynamic_versioning-1.4.0/PKG-INFO new/poetry_dynamic_versioning-1.4.1/PKG-INFO --- old/poetry_dynamic_versioning-1.4.0/PKG-INFO 1970-01-01 01:00:00.000000000 +0100 +++ new/poetry_dynamic_versioning-1.4.1/PKG-INFO 1970-01-01 01:00:00.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: poetry-dynamic-versioning -Version: 1.4.0 +Version: 1.4.1 Summary: Plugin for Poetry to enable dynamic versioning based on VCS tags Home-page: https://github.com/mtkennerly/poetry-dynamic-versioning License: MIT @@ -20,6 +20,7 @@ Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.11 +Classifier: Programming Language :: Python :: 3.12 Classifier: Topic :: Software Development :: Version Control Classifier: Topic :: Software Development :: Version Control :: Bazaar Classifier: Topic :: Software Development :: Version Control :: Git @@ -135,7 +136,14 @@ poetry run python -c "import dunamai; print(dunamai.Pattern.Default.regex())" ``` - Remember that backslashes must be escaped (`\\`) in the TOML file. + Remember that backslashes must be escaped in the TOML file. + + ```toml + # Regular expression: + pattern = '(?P<base>\d+\.\d+\.\d+)' + # Named preset: + pattern = "default-unprefixed" + ``` * `pattern-prefix` (string): This will be inserted after the pattern's start anchor (`^`). For example, to match tags like `some-package-v1.2.3`, @@ -283,12 +291,12 @@ ```toml patterns = [ - "(^__version__\\s*(?::.*?)?=\\s*['\"])[^'\"]*(['\"])", - { value = "(^__version_tuple__\\s*(?::.*?)?=\\s*\\()[^)]*(\\))", mode = "tuple" }, + '''(^__version__\s*(?::.*?)?=\s*['"])[^'"]*(['"])''', + { value = '''(^__version_tuple__\s*(?::.*?)?=\s*\()[^)]*(\))''', mode = "tuple" }, ] ``` - Remember that the backslashes must be escaped (`\\`) in the TOML file. + Remember that the backslashes must be escaped in the TOML file. * `folders` (array of tables, default: empty): List of additional folders to check for substitutions. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/poetry_dynamic_versioning-1.4.0/README.md new/poetry_dynamic_versioning-1.4.1/README.md --- old/poetry_dynamic_versioning-1.4.0/README.md 2024-04-30 05:00:13.691434600 +0200 +++ new/poetry_dynamic_versioning-1.4.1/README.md 2024-06-26 03:57:50.717621600 +0200 @@ -101,7 +101,14 @@ poetry run python -c "import dunamai; print(dunamai.Pattern.Default.regex())" ``` - Remember that backslashes must be escaped (`\\`) in the TOML file. + Remember that backslashes must be escaped in the TOML file. + + ```toml + # Regular expression: + pattern = '(?P<base>\d+\.\d+\.\d+)' + # Named preset: + pattern = "default-unprefixed" + ``` * `pattern-prefix` (string): This will be inserted after the pattern's start anchor (`^`). For example, to match tags like `some-package-v1.2.3`, @@ -249,12 +256,12 @@ ```toml patterns = [ - "(^__version__\\s*(?::.*?)?=\\s*['\"])[^'\"]*(['\"])", - { value = "(^__version_tuple__\\s*(?::.*?)?=\\s*\\()[^)]*(\\))", mode = "tuple" }, + '''(^__version__\s*(?::.*?)?=\s*['"])[^'"]*(['"])''', + { value = '''(^__version_tuple__\s*(?::.*?)?=\s*\()[^)]*(\))''', mode = "tuple" }, ] ``` - Remember that the backslashes must be escaped (`\\`) in the TOML file. + Remember that the backslashes must be escaped in the TOML file. * `folders` (array of tables, default: empty): List of additional folders to check for substitutions. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/poetry_dynamic_versioning-1.4.0/poetry_dynamic_versioning/__init__.py new/poetry_dynamic_versioning-1.4.1/poetry_dynamic_versioning/__init__.py --- old/poetry_dynamic_versioning-1.4.0/poetry_dynamic_versioning/__init__.py 2024-06-18 00:02:36.863616000 +0200 +++ new/poetry_dynamic_versioning-1.4.1/poetry_dynamic_versioning/__init__.py 2024-06-27 05:04:01.023227700 +0200 @@ -139,9 +139,7 @@ self.version = version self.mode = mode self.dynamic_index = dynamic_index - self.substitutions = ( - {} if substitutions is None else substitutions - ) # type: MutableMapping[Path, str] + self.substitutions = {} if substitutions is None else substitutions # type: MutableMapping[Path, str] class _State: @@ -297,9 +295,7 @@ if isinstance(local, tomlkit.TOMLDocument): local = local.unwrap() - merged = _deep_merge_dicts(_default_config(), local)["tool"][ - "poetry-dynamic-versioning" - ] # type: _Config + merged = _deep_merge_dicts(_default_config(), local)["tool"]["poetry-dynamic-versioning"] # type: _Config # Add default values so we don't have to worry about missing keys for x in merged["files"].values(): @@ -340,9 +336,7 @@ ) -def _validate_config_section( - config: Mapping, default: Mapping, path: Sequence[str] -) -> Sequence[str]: +def _validate_config_section(config: Mapping, default: Mapping, path: Sequence[str]) -> Sequence[str]: if not default: return [] @@ -370,9 +364,7 @@ return value.strftime("%Y%m%d%H%M%S") -def _render_jinja( - version: Version, template: str, config: _Config, extra: Optional[Mapping] = None -) -> str: +def _render_jinja(version: Version, template: str, config: _Config, extra: Optional[Mapping] = None) -> str: if extra is None: extra = {} @@ -417,11 +409,7 @@ ) output = result.stdout.decode().strip() if codes and result.returncode not in codes: - raise RuntimeError( - "The command '{}' returned code {}. Output:\n{}".format( - command, result.returncode, output - ) - ) + raise RuntimeError("The command '{}' returned code {}. Output:\n{}".format(command, result.returncode, output)) return (result.returncode, output) @@ -496,9 +484,7 @@ vcs = Vcs(config["vcs"]) style = Style(config["style"]) if config["style"] is not None else None - pattern = ( - config["pattern"] if config["pattern"] is not None else Pattern.Default - ) # type: Union[str, Pattern] + pattern = config["pattern"] if config["pattern"] is not None else Pattern.Default # type: Union[str, Pattern] if config["fix-shallow-repository"]: # We start without strict so we can inspect the concerns. @@ -553,11 +539,7 @@ files[resolved] = folder if i == 0: - _debug( - "No files found for substitution with glob '{}' in folder '{}'".format( - file_glob, folder.path - ) - ) + _debug("No files found for substitution with glob '{}' in folder '{}'".format(file_glob, folder.path)) for file, config in files.items(): original_content = file.read_bytes().decode("utf-8") @@ -592,9 +574,7 @@ else: raise ValueError("Invalid substitution mode: {}".format(pattern.mode)) - new_content = re.sub( - pattern.value, r"\g<1>{}\g<2>".format(insert), new_content, flags=re.MULTILINE - ) + new_content = re.sub(pattern.value, r"\g<1>{}\g<2>".format(insert), new_content, flags=re.MULTILINE) return new_content @@ -667,11 +647,7 @@ if pyproject is None: pyproject = tomlkit.parse(pyproject_path.read_bytes().decode("utf-8")) - classic = ( - "tool" in pyproject - and "poetry" in pyproject["tool"] - and "name" in pyproject["tool"]["poetry"] - ) + classic = "tool" in pyproject and "poetry" in pyproject["tool"] and "name" in pyproject["tool"]["poetry"] pep621 = ( "project" in pyproject and "name" in pyproject["project"] @@ -708,16 +684,12 @@ if classic and name is not None and original is not None: mode = _Mode.Classic - _state.projects[name] = _ProjectState( - pyproject_path, original, version, mode, dynamic_index - ) + _state.projects[name] = _ProjectState(pyproject_path, original, version, mode, dynamic_index) if io: _apply_version(name, version, instance, config, pyproject_path, mode, retain) elif pep621 and name is not None: mode = _Mode.Pep621 - _state.projects[name] = _ProjectState( - pyproject_path, original, version, mode, dynamic_index - ) + _state.projects[name] = _ProjectState(pyproject_path, original, version, mode, dynamic_index) if io: _apply_version(name, version, instance, config, pyproject_path, mode, retain) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/poetry_dynamic_versioning-1.4.0/poetry_dynamic_versioning/cli.py new/poetry_dynamic_versioning-1.4.1/poetry_dynamic_versioning/cli.py --- old/poetry_dynamic_versioning-1.4.0/poetry_dynamic_versioning/cli.py 2024-06-18 00:02:36.864616400 +0200 +++ new/poetry_dynamic_versioning-1.4.1/poetry_dynamic_versioning/cli.py 2024-09-10 05:57:28.868856700 +0200 @@ -45,13 +45,17 @@ ) -def parse_args(argv=None) -> argparse.Namespace: +def get_parser() -> argparse.ArgumentParser: parser = argparse.ArgumentParser(description=Help.main) subparsers = parser.add_subparsers(dest="cmd", title="subcommands") subparsers.add_parser(Command.enable, help=Help.enable) - return parser.parse_args(argv) + return parser + + +def parse_args(argv=None) -> argparse.Namespace: + return get_parser().parse_args(argv) def validate(*, standalone: bool, config: Optional[Mapping] = None) -> None: @@ -101,20 +105,18 @@ tool_table = tomlkit.table().add(Key.pdv, pdv_table) if doc.get(Key.tool) is None: - doc.add(Key.tool, tool_table) + doc[Key.tool] = tool_table elif doc[Key.tool].get(Key.pdv) is None: # type: ignore - doc[Key.tool].add(Key.pdv, pdv_table) # type: ignore + doc[Key.tool][Key.pdv] = pdv_table # type: ignore else: doc[Key.tool][Key.pdv].update(pdv_table) # type: ignore build_system_table = ( - tomlkit.table() - .add(Key.requires, _DEFAULT_REQUIRES) - .add(Key.build_backend, _DEFAULT_BUILD_BACKEND) + tomlkit.table().add(Key.requires, _DEFAULT_REQUIRES).add(Key.build_backend, _DEFAULT_BUILD_BACKEND) ) if doc.get(Key.build_system) is None: - doc.add(Key.build_system, build_system_table) + doc[Key.build_system] = build_system_table else: doc[Key.build_system].update(build_system_table) # type: ignore diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/poetry_dynamic_versioning-1.4.0/poetry_dynamic_versioning/plugin.py new/poetry_dynamic_versioning-1.4.1/poetry_dynamic_versioning/plugin.py --- old/poetry_dynamic_versioning-1.4.0/poetry_dynamic_versioning/plugin.py 2024-06-17 23:45:11.044512500 +0200 +++ new/poetry_dynamic_versioning-1.4.1/poetry_dynamic_versioning/plugin.py 2024-06-27 05:04:00.675025500 +0200 @@ -110,9 +110,7 @@ def handle(self) -> int: _state.cli_mode = True - _apply_version_via_plugin( - self._application.poetry, retain=True, force=True, standalone=True - ) + _apply_version_via_plugin(self._application.poetry, retain=True, force=True, standalone=True) return 0 @@ -137,9 +135,7 @@ def activate(self, application: Application) -> None: self._application = application - application.command_loader.register_factory( - cli.Command.dv, lambda: DynamicVersioningCommand(application) - ) + application.command_loader.register_factory(cli.Command.dv, lambda: DynamicVersioningCommand(application)) application.command_loader.register_factory( cli.Command.dv_enable, lambda: DynamicVersioningEnableCommand(application) ) @@ -161,9 +157,7 @@ application.event_dispatcher.add_listener(TERMINATE, self._revert_version) application.event_dispatcher.add_listener(ERROR, self._revert_version) - def _apply_version( - self, event: ConsoleCommandEvent, kind: str, dispatcher: EventDispatcher - ) -> None: + def _apply_version(self, event: ConsoleCommandEvent, kind: str, dispatcher: EventDispatcher) -> None: if not _should_apply(event.command.name): return @@ -172,9 +166,7 @@ _apply_version_via_plugin(self._application.poetry, io=io) _patch_dependency_versions(io) - def _revert_version( - self, event: ConsoleCommandEvent, kind: str, dispatcher: EventDispatcher - ) -> None: + def _revert_version(self, event: ConsoleCommandEvent, kind: str, dispatcher: EventDispatcher) -> None: if not _should_apply(event.command.name): return diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/poetry_dynamic_versioning-1.4.0/pyproject.toml new/poetry_dynamic_versioning-1.4.1/pyproject.toml --- old/poetry_dynamic_versioning-1.4.0/pyproject.toml 2024-06-17 23:52:03.505818100 +0200 +++ new/poetry_dynamic_versioning-1.4.1/pyproject.toml 2024-09-11 01:00:04.169514200 +0200 @@ -1,6 +1,6 @@ [tool.poetry] name = "poetry-dynamic-versioning" -version = "1.4.0" +version = "1.4.1" description = "Plugin for Poetry to enable dynamic versioning based on VCS tags" license = "MIT" authors = ["Matthew T. Kennerly <mtkenne...@gmail.com>"] @@ -41,6 +41,7 @@ black = "^22.8" mypy = "^0.971" ruff = {version = "^0.0.272", python = "^3.7"} +argparse-manpage = "^4.6" [tool.poetry.scripts] poetry-dynamic-versioning = 'poetry_dynamic_versioning.__main__:main' @@ -49,13 +50,13 @@ poetry-dynamic-versioning = "poetry_dynamic_versioning.plugin:DynamicVersioningPlugin" [tool.black] -line-length = 100 +line-length = 120 [tool.mypy] allow_redefinition = true [tool.ruff] -line-length = 100 +line-length = 120 extend-select = ["W605", "N"] [build-system] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/poetry_dynamic_versioning-1.4.0/tests/test_integration.py new/poetry_dynamic_versioning-1.4.1/tests/test_integration.py --- old/poetry_dynamic_versioning-1.4.0/tests/test_integration.py 2024-06-17 23:45:11.045522500 +0200 +++ new/poetry_dynamic_versioning-1.4.1/tests/test_integration.py 2024-09-10 04:48:00.262283800 +0200 @@ -47,11 +47,7 @@ ) output = result.stdout.decode("utf-8", errors="ignore").strip() if codes and result.returncode not in codes: - raise RuntimeError( - "The command '{}' returned code {}. Output:\n{}".format( - command, result.returncode, output - ) - ) + raise RuntimeError("The command '{}' returned code {}. Output:\n{}".format(command, result.returncode, output)) return (result.returncode, output) @@ -62,19 +58,37 @@ path.unlink() +def install_plugin(artifact: str) -> None: + pipx = os.environ.get("POETRY_DYNAMIC_VERSIONING_TEST_INSTALLATION") == "pipx" + + if pipx: + run(f'pipx inject poetry "{artifact}[plugin]"') + else: + run(f'poetry self add "{artifact}[plugin]"') + + +def uninstall_plugin() -> None: + pipx = os.environ.get("POETRY_DYNAMIC_VERSIONING_TEST_INSTALLATION") == "pipx" + + if pipx: + run("pipx uninject poetry poetry-dynamic-versioning", codes=[0, 1]) + else: + run("poetry self remove poetry-dynamic-versioning", codes=[0, 1]) + + @pytest.fixture(scope="module", autouse=True) def before_all(): - run("poetry self remove poetry-dynamic-versioning", codes=[0, 1]) + uninstall_plugin() delete(DIST) delete(DUMMY / ".venv") run("poetry build", where=ROOT) artifact = next(DIST.glob("*.whl")) - run(f'poetry self add "{artifact}[plugin]"') + install_plugin(artifact) yield run(f'git checkout -- "{DUMMY.as_posix()}" "{ROOT.as_posix()}/tests/dependency-*"') - run("poetry self remove poetry-dynamic-versioning", codes=[0, 1]) + uninstall_plugin() @pytest.fixture(autouse=True) @@ -158,15 +172,9 @@ run("poetry dynamic-versioning", where=DUMMY) # Changes persist after the command is done: assert f'version = "{DUMMY_VERSION}"' not in DUMMY_PYPROJECT.read_bytes().decode("utf-8") - assert '__version__: str = "0.0.0"' not in ( - DUMMY / "project" / "__init__.py" - ).read_bytes().decode("utf-8") - assert '__version__ = "0.0.0"' not in (DUMMY / "project" / "__init__.py").read_bytes().decode( - "utf-8" - ) - assert "__version_tuple__ = (0, 0, 0)" not in (DUMMY / "project" / "__init__.py").read_text( - "utf8" - ) + assert '__version__: str = "0.0.0"' not in (DUMMY / "project" / "__init__.py").read_bytes().decode("utf-8") + assert '__version__ = "0.0.0"' not in (DUMMY / "project" / "__init__.py").read_bytes().decode("utf-8") + assert "__version_tuple__ = (0, 0, 0)" not in (DUMMY / "project" / "__init__.py").read_text("utf8") assert "<0.0.0>" not in (DUMMY / "project" / "__init__.py").read_bytes().decode("utf-8") @@ -174,15 +182,9 @@ run("poetry-dynamic-versioning", where=DUMMY) # Changes persist after the command is done: assert f'version = "{DUMMY_VERSION}"' not in DUMMY_PYPROJECT.read_bytes().decode("utf-8") - assert '__version__: str = "0.0.0"' not in ( - DUMMY / "project" / "__init__.py" - ).read_bytes().decode("utf-8") - assert '__version__ = "0.0.0"' not in (DUMMY / "project" / "__init__.py").read_bytes().decode( - "utf-8" - ) - assert "__version_tuple__ = (0, 0, 0)" not in (DUMMY / "project" / "__init__.py").read_text( - "utf8" - ) + assert '__version__: str = "0.0.0"' not in (DUMMY / "project" / "__init__.py").read_bytes().decode("utf-8") + assert '__version__ = "0.0.0"' not in (DUMMY / "project" / "__init__.py").read_bytes().decode("utf-8") + assert "__version_tuple__ = (0, 0, 0)" not in (DUMMY / "project" / "__init__.py").read_text("utf8") assert "<0.0.0>" not in (DUMMY / "project" / "__init__.py").read_bytes().decode("utf-8") @@ -194,15 +196,9 @@ run("poetry dynamic-versioning", where=DUMMY) # Changes persist after the command is done: assert f'version = "{DUMMY_VERSION}"' not in DUMMY_PYPROJECT.read_bytes().decode("utf-8") - assert '__version__: str = "0.0.0"' not in ( - DUMMY / "project" / "__init__.py" - ).read_bytes().decode("utf-8") - assert '__version__ = "0.0.0"' not in (DUMMY / "project" / "__init__.py").read_bytes().decode( - "utf-8" - ) - assert "__version_tuple__ = (0, 0, 0)" not in (DUMMY / "project" / "__init__.py").read_text( - "utf8" - ) + assert '__version__: str = "0.0.0"' not in (DUMMY / "project" / "__init__.py").read_bytes().decode("utf-8") + assert '__version__ = "0.0.0"' not in (DUMMY / "project" / "__init__.py").read_bytes().decode("utf-8") + assert "__version_tuple__ = (0, 0, 0)" not in (DUMMY / "project" / "__init__.py").read_text("utf8") assert "<0.0.0>" not in (DUMMY / "project" / "__init__.py").read_bytes().decode("utf-8") @@ -267,15 +263,10 @@ assert "-1.2.3-" in artifact.name +@pytest.mark.skipif("CI" in os.environ, reason="CI uses Pipx, which doesn't play nice with this 'poetry self'") def test_plugin_show(): _, out = run("poetry self show") - - # This is flaky during CI for some reason. - # There's no error from Poetry, but the plugin isn't always listed, - # even though it's installed and usable. - # Just skip it for now. - if "CI" not in os.environ: - assert "poetry-dynamic-versioning" in out + assert "poetry-dynamic-versioning" in out @pytest.mark.skipif("USE_PEP621" not in os.environ, reason="Requires Poetry with PEP-621 support") @@ -286,9 +277,9 @@ pyproject = tomlkit.parse(DUMMY_PEP621_PYPROJECT.read_bytes().decode("utf-8")) assert pyproject["project"]["version"] == version assert "version" not in pyproject["project"]["dynamic"] - assert f'__version__ = "{version}"' in ( - DUMMY_PEP621 / "project_pep621" / "__init__.py" - ).read_bytes().decode("utf-8") + assert f'__version__ = "{version}"' in (DUMMY_PEP621 / "project_pep621" / "__init__.py").read_bytes().decode( + "utf-8" + ) @pytest.mark.skipif("USE_PEP621" not in os.environ, reason="Requires Poetry with PEP-621 support") @@ -299,9 +290,7 @@ pyproject = tomlkit.parse(DUMMY_PEP621_PYPROJECT.read_bytes().decode("utf-8")) assert "version" not in pyproject["project"] assert "version" in pyproject["project"]["dynamic"] - assert '__version__ = "0.0.0"' in ( - DUMMY_PEP621 / "project_pep621" / "__init__.py" - ).read_bytes().decode("utf-8") + assert '__version__ = "0.0.0"' in (DUMMY_PEP621 / "project_pep621" / "__init__.py").read_bytes().decode("utf-8") artifact = next(DUMMY_PEP621_DIST.glob("*.whl")) assert f"-{version}-" in artifact.name @@ -316,6 +305,4 @@ run("poetry-dynamic-versioning", codes=[1], where=DUMMY_PEP621) pyproject = tomlkit.parse(DUMMY_PEP621_PYPROJECT.read_bytes().decode("utf-8")) assert "version" not in pyproject["project"] - assert '__version__ = "0.0.0"' in ( - DUMMY_PEP621 / "project_pep621" / "__init__.py" - ).read_bytes().decode("utf-8") + assert '__version__ = "0.0.0"' in (DUMMY_PEP621 / "project_pep621" / "__init__.py").read_bytes().decode("utf-8") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/poetry_dynamic_versioning-1.4.0/tests/test_unit.py new/poetry_dynamic_versioning-1.4.1/tests/test_unit.py --- old/poetry_dynamic_versioning-1.4.0/tests/test_unit.py 2023-12-02 14:49:24.976830200 +0100 +++ new/poetry_dynamic_versioning-1.4.1/tests/test_unit.py 2024-09-10 05:57:28.870102200 +0200 @@ -26,9 +26,7 @@ def test__find_higher_file(): assert plugin._find_higher_file("pyproject.toml", start=root) == root / "pyproject.toml" - assert ( - plugin._find_higher_file("pyproject.toml", start=root / "tests") == root / "pyproject.toml" - ) + assert plugin._find_higher_file("pyproject.toml", start=root / "tests") == root / "pyproject.toml" assert ( plugin._find_higher_file("pyproject.toml", start=root / "tests" / "project") == root / "tests" / "project" / "pyproject.toml" @@ -113,9 +111,6 @@ def test__enable_in_doc__empty(): doc = tomlkit.parse("") updated = cli._enable_in_doc(doc) - assert updated[cli.Key.tool][cli.Key.pdv][cli.Key.enable] is True - assert updated[cli.Key.build_system][cli.Key.requires] == cli._DEFAULT_REQUIRES - assert updated[cli.Key.build_system][cli.Key.build_backend] == cli._DEFAULT_BUILD_BACKEND assert ( tomlkit.dumps(updated) == textwrap.dedent( @@ -141,9 +136,19 @@ ) ) updated = cli._enable_in_doc(doc) - assert updated[cli.Key.tool][cli.Key.pdv][cli.Key.enable] is True - assert updated[cli.Key.build_system][cli.Key.requires] == cli._DEFAULT_REQUIRES - assert updated[cli.Key.build_system][cli.Key.build_backend] == cli._DEFAULT_BUILD_BACKEND + assert tomlkit.dumps(updated) == textwrap.dedent( + """ + [tool] + foo = 1 + + [tool.poetry-dynamic-versioning] + enable = true + + [build-system] + requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"] + build-backend = "poetry_dynamic_versioning.backend" + """ + ) def test__enable_in_doc__updated_enable(): @@ -156,9 +161,16 @@ ) ) updated = cli._enable_in_doc(doc) - assert updated[cli.Key.tool][cli.Key.pdv][cli.Key.enable] is True - assert updated[cli.Key.build_system][cli.Key.requires] == cli._DEFAULT_REQUIRES - assert updated[cli.Key.build_system][cli.Key.build_backend] == cli._DEFAULT_BUILD_BACKEND + assert tomlkit.dumps(updated) == textwrap.dedent( + """ + [tool.poetry-dynamic-versioning] + enable = true + + [build-system] + requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"] + build-backend = "poetry_dynamic_versioning.backend" + """ + ) def test__enable_in_doc__updated_requires(): @@ -171,9 +183,16 @@ ) ) updated = cli._enable_in_doc(doc) - assert updated[cli.Key.tool][cli.Key.pdv][cli.Key.enable] is True - assert updated[cli.Key.build_system][cli.Key.requires] == cli._DEFAULT_REQUIRES - assert updated[cli.Key.build_system][cli.Key.build_backend] == cli._DEFAULT_BUILD_BACKEND + assert tomlkit.dumps(updated) == textwrap.dedent( + """ + [build-system] + requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"] + build-backend = "poetry_dynamic_versioning.backend" + + [tool.poetry-dynamic-versioning] + enable = true + """ + ) def test__enable_in_doc__updated_build_backend(): @@ -186,9 +205,49 @@ ) ) updated = cli._enable_in_doc(doc) - assert updated[cli.Key.tool][cli.Key.pdv][cli.Key.enable] is True - assert updated[cli.Key.build_system][cli.Key.requires] == cli._DEFAULT_REQUIRES - assert updated[cli.Key.build_system][cli.Key.build_backend] == cli._DEFAULT_BUILD_BACKEND + assert tomlkit.dumps(updated) == textwrap.dedent( + """ + [build-system] + build-backend = "poetry_dynamic_versioning.backend" + requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"] + + [tool.poetry-dynamic-versioning] + enable = true + """ + ) + + +def test__enable_in_doc__out_of_order_tables(): + doc = tomlkit.parse( + textwrap.dedent( + """ + [tool.poetry] + name = "foo" + + [build-system] + build-backend = "" + + [tool.poetry.dependencies] + python = "^3.10" + """ + ) + ) + updated = cli._enable_in_doc(doc) + assert tomlkit.dumps(updated) == textwrap.dedent( + """ + [tool.poetry] + name = "foo" + + [tool.poetry-dynamic-versioning] + enable = true + [build-system] + build-backend = "poetry_dynamic_versioning.backend" + requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"] + + [tool.poetry.dependencies] + python = "^3.10" + """ + ) def test__substitute_version_in_text__integers_only():