Skip to content

Commit af8318a

Browse files
SIPR-octossbarnea
andauthored
docs: Add missing type and parameter in custom-rules.rst (#1764)
* 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]>
1 parent 93fe2ea commit af8318a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

docs/custom-rules.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,23 @@ An example rule using ``matchtask`` is:
4646

4747
.. code-block:: python
4848
49-
from typing import Any, Dict
49+
from typing import TYPE_CHECKING, Any, Dict, Union
5050
5151
import ansiblelint.utils
5252
from ansiblelint.rules import AnsibleLintRule
5353
54+
if TYPE_CHECKING:
55+
from typing import Optional
56+
57+
from ansiblelint.file_utils import Lintable
58+
5459
class TaskHasTag(AnsibleLintRule):
5560
id = 'EXAMPLE001'
5661
shortdesc = 'Tasks must have tag'
5762
description = 'Tasks must have tag'
5863
tags = ['productivity']
5964
60-
def matchtask(self, task: Dict[str, Any]) -> Union[bool,str]:
65+
def matchtask(self, task: Dict[str, Any], file: 'Optional[Lintable]' = None) -> Union[bool,str]:
6166
# If the task include another task or make the playbook fail
6267
# Don't force to have a tag
6368
if not set(task.keys()).isdisjoint(['include','fail']):

0 commit comments

Comments
 (0)