Skip to content

Commit

Permalink
docs: Add missing type and parameter in custom-rules.rst (#1764)
Browse files Browse the repository at this point in the history
* docs: Add missing type and parameter in custom-rules.rst

* docs: Add type for file parameter

Co-authored-by: Simon - SIPR <[email protected]>
Co-authored-by: Sorin Sbarnea <[email protected]>
  • Loading branch information
3 people authored Nov 30, 2021
1 parent 93fe2ea commit af8318a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions docs/custom-rules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,23 @@ An example rule using ``matchtask`` is:

.. code-block:: python
from typing import Any, Dict
from typing import TYPE_CHECKING, Any, Dict, Union
import ansiblelint.utils
from ansiblelint.rules import AnsibleLintRule
if TYPE_CHECKING:
from typing import Optional
from ansiblelint.file_utils import Lintable
class TaskHasTag(AnsibleLintRule):
id = 'EXAMPLE001'
shortdesc = 'Tasks must have tag'
description = 'Tasks must have tag'
tags = ['productivity']
def matchtask(self, task: Dict[str, Any]) -> Union[bool,str]:
def matchtask(self, task: Dict[str, Any], file: 'Optional[Lintable]' = None) -> Union[bool,str]:
# If the task include another task or make the playbook fail
# Don't force to have a tag
if not set(task.keys()).isdisjoint(['include','fail']):
Expand Down

0 comments on commit af8318a

Please sign in to comment.