From 9bbd22cf0a3571c923e2db091a7cd7ac4ef30e84 Mon Sep 17 00:00:00 2001 From: David Salvisberg Date: Wed, 28 Aug 2024 17:09:21 +0200 Subject: [PATCH] Fixes version hint for non-core modules Switches to bump-my-version --- .bumpversion.cfg | 19 ------------------- README.rst | 12 +++++++++++- pyproject.toml | 27 +++++++++++++++++++++++++++ scripts/generate_module_hints.py | 18 ++++++++++++++---- setup.cfg | 1 + src/suitable/_modules.py | 8 +------- 6 files changed, 54 insertions(+), 31 deletions(-) delete mode 100644 .bumpversion.cfg diff --git a/.bumpversion.cfg b/.bumpversion.cfg deleted file mode 100644 index def8f58..0000000 --- a/.bumpversion.cfg +++ /dev/null @@ -1,19 +0,0 @@ -[bumpversion] -current_version = 0.19.2 -commit = True -tag = True -message = Release {new_version} - -[bumpversion:file:setup.cfg] - -[bumpversion:file:docs/source/conf.py] - -[bumpversion:file:README.rst] -search = - Changelog - --------- -replace = - Changelog - --------- - {new_version} ({now:%Y-%m-%d}) - ~~~~~~~~~~~~~~~~~~~ diff --git a/README.rst b/README.rst index 0575a10..7b7913a 100644 --- a/README.rst +++ b/README.rst @@ -61,8 +61,18 @@ Latest Release Changelog --------- +- Raises minimum Ansible version to 6 + [Daverball] + +- Adds Python 3.12 support + [Daverball] + +- Adds proper support for Ansible 8+ + [Daverball] + - Adds basic auto-generated stubs and docs for `Api` methods - created through hooked Ansible modules + created through hooked Ansible modules, for now this only + includes collections in the ansible namespace [Daverball] 0.19.2 (2024-08-22) diff --git a/pyproject.toml b/pyproject.toml index fa27388..c5c8fb2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,6 +29,33 @@ mypy_path = "$MYPY_CONFIG_FILE_DIR/src" module = ["suitable._module_types"] warn_return_any = false +[tool.bumpversion] +current_version = "0.21.0" +commit = true +message = "Release {new_version}" +tag = true +tag_message = "Release {new_version}" + +[[tool.bumpversion.files]] +filename="setup.cfg" + +[[tool.bumpversion.files]] +filename="docs/conf.py" + +[[tool.bumpversion.files]] +filename="README.rst" +search = """ +Changelog +--------- +""" +replace = """ +Changelog +--------- + +{new_version} ({now:%Y-%m-%d}) +~~~~~~~~~~~~~~~~~~~ +""" + [tool.tox] legacy_tox_ini = """ [tox] diff --git a/scripts/generate_module_hints.py b/scripts/generate_module_hints.py index e0058e6..4ba677f 100755 --- a/scripts/generate_module_hints.py +++ b/scripts/generate_module_hints.py @@ -27,7 +27,8 @@ C.DEPRECATION_WARNINGS = False # Make sure we can load all the collection plugins we want to init_plugin_loader([]) -version_hint_above = (2, 13) +core_version_hint_above = (2, 13) +ansible_version_hint_above = (6, ) reference_re = re.compile(r'([MLBIUROCVEP]|RV)\(([^)]+)\)') modules_py = StringIO() modules_header_py = StringIO() @@ -294,7 +295,7 @@ def write_function_docstring(options: dict[str, Any] | None) -> None: if version(added := docs.get('version_added', 0)) > version_hint_above: modules_py.write( - f'\n .. note:: Requires ansible-core >= {added}\n' + f'\n .. note:: Requires {version_hint_package} >= {added}\n' ) if conflicts := docs.get('conflicts'): @@ -344,7 +345,7 @@ def write_function_docstring(options: dict[str, Any] | None) -> None: added = meta.get('version_added') if added and version(added) > version_hint_above: modules_py.write( - f' Requires ansible-core >= {added}\n' + f' Requires {version_hint_package} >= {added}\n' ) @@ -417,7 +418,8 @@ def write_return_type(returns: dict[str, Any] | None) -> None: added = meta.get('version_added') if added and version(added) > version_hint_above: types_py.write( - f'\n .. note:: Requires ansible-core >= {added}\n' + f'\n .. note:: Requires {version_hint_package} ' + f'>= {added}\n' ) global exceeded_line_limit @@ -521,10 +523,18 @@ def type_check_only(f): return f ''') current_collection = '' +version_hint_above: tuple[int, ...] for module_name, (collection, docs, returns) in sorted( modules.items(), key=lambda i: (i[1][0], i[0]) ): + if collection == 'ansible.builtin': + version_hint_above = core_version_hint_above + version_hint_package = 'ansible-core' + else: + version_hint_above = ansible_version_hint_above + version_hint_package = 'ansible' + if current_collection != collection: modules_py.write('\n #\n') types_py.write('\n\n#\n') diff --git a/setup.cfg b/setup.cfg index 4ff4d18..ed4ca96 100644 --- a/setup.cfg +++ b/setup.cfg @@ -43,6 +43,7 @@ install_requires = [options.extras_require] dev = + bump-my-version bandit[toml] flake8 flake8-bugbear diff --git a/src/suitable/_modules.py b/src/suitable/_modules.py index 70d7b34..fbf3260 100644 --- a/src/suitable/_modules.py +++ b/src/suitable/_modules.py @@ -6350,8 +6350,6 @@ def cli_backup( .. seealso:: :ref:`ansible.netcommon ` - .. note:: Requires ansible-core >= 4.2.0 - :param defaults: The *defaults* argument will influence how the running-config is collected from the device. When the value is set to true, the @@ -6536,7 +6534,7 @@ def cli_restore( .. seealso:: :ref:`ansible.netcommon ` - .. note:: Requires ansible-core >= 6.1.0 + .. note:: Requires ansible >= 6.1.0 :param filename: Filename of the backup file, present in the appliance where the @@ -6564,8 +6562,6 @@ def grpc_config( .. seealso:: :ref:`ansible.netcommon ` - .. note:: Requires ansible-core >= 3.1.0 - :param config: This option specifies the string which acts as a filter to restrict the portions of the data to be retrieved from the target @@ -6603,8 +6599,6 @@ def grpc_get( .. seealso:: :ref:`ansible.netcommon ` - .. note:: Requires ansible-core >= 3.1.0 - :param section: This option specifies the string which acts as a filter to restrict the portions of the data to be retrieved from the target