Skip to content

Commit

Permalink
Fixes version hint for non-core modules
Browse files Browse the repository at this point in the history
Switches to bump-my-version
  • Loading branch information
Daverball committed Aug 28, 2024
1 parent 24082b5 commit 9bbd22c
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 31 deletions.
19 changes: 0 additions & 19 deletions .bumpversion.cfg

This file was deleted.

12 changes: 11 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
27 changes: 27 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
18 changes: 14 additions & 4 deletions scripts/generate_module_hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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'):
Expand Down Expand Up @@ -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'
)


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ install_requires =

[options.extras_require]
dev =
bump-my-version
bandit[toml]
flake8
flake8-bugbear
Expand Down
8 changes: 1 addition & 7 deletions src/suitable/_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -6350,8 +6350,6 @@ def cli_backup(
.. seealso::
:ref:`ansible.netcommon <ansible_collections.ansible.netcommon.cli_backup_module>`
.. 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
Expand Down Expand Up @@ -6536,7 +6534,7 @@ def cli_restore(
.. seealso::
:ref:`ansible.netcommon <ansible_collections.ansible.netcommon.cli_restore_module>`
.. 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
Expand Down Expand Up @@ -6564,8 +6562,6 @@ def grpc_config(
.. seealso::
:ref:`ansible.netcommon <ansible_collections.ansible.netcommon.grpc_config_module>`
.. 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
Expand Down Expand Up @@ -6603,8 +6599,6 @@ def grpc_get(
.. seealso::
:ref:`ansible.netcommon <ansible_collections.ansible.netcommon.grpc_get_module>`
.. 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
Expand Down

0 comments on commit 9bbd22c

Please sign in to comment.