Skip to content

Fix: fix mock_modules generated stubs failing YAML/doc parsing #5031#5032

Open
santosh7676 wants to merge 4 commits intoansible:mainfrom
santosh7676:fix_mock_module_lint_issue
Open

Fix: fix mock_modules generated stubs failing YAML/doc parsing #5031#5032
santosh7676 wants to merge 4 commits intoansible:mainfrom
santosh7676:fix_mock_module_lint_issue

Conversation

@santosh7676
Copy link
Copy Markdown

@santosh7676 santosh7676 commented Apr 28, 2026

Fix mock_modules generated stubs failing YAML/doc parsing

This MR fixes a bug where mock_modules generated Python stubs could fail ansible-lint checks due to invalid module-doc block content.

Problem

When using mock_modules, generated stubs used:

  • EXAMPLES = '''mocked'''
  • RETURN = '''mocked'''

In some environments/paths, these values triggered YAML/module-doc parsing failures and caused lint errors on generated mock module files.

Fix

  • Updated mocked module template to:
  • use valid YAML content in EXAMPLES
  • use the no-return sentinel for RETURN (r""" + # """)

Tests

  • Added a regression test in test/test_mockings.py to cover the mock_modules scenario and ensure generated stubs are lintable.

#5013

@santosh7676
Copy link
Copy Markdown
Author

Looks like CI Issue, it is failing in test_import_tasks[1] (Runner lintables count for examples/playbooks/test_import_with_malformed.yml), in both py314-devel and py312-devel jobs.

This PR only changes:

  • src/ansiblelint/constants.py (mocked module template docs)
  • test/test_mockings.py (mock_modules regression test)

So this appears unrelated/pre-existing.

@felixfontein
Copy link
Copy Markdown
Contributor

Yep, the CI seems to be broken at the moment...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants