Skip to content

Commit

Permalink
Ansible already knows how to get examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Qalthos committed Apr 14, 2023
1 parent 4888597 commit f64c4c1
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/ansiblelint/file_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Utility functions related to file operations."""
from __future__ import annotations

import ast
import copy
import logging
import os
Expand All @@ -15,6 +14,7 @@
from tempfile import NamedTemporaryFile
from typing import TYPE_CHECKING, Any, Iterator, cast

from ansible.parsing.plugin_docs import read_docstring
import wcmatch.pathlib
from wcmatch.wcmatch import RECURSIVE, WcMatch
from yaml.error import YAMLError
Expand Down Expand Up @@ -376,15 +376,8 @@ def parse_examples_from_plugin(self) -> str:
The line numbers are stored in each node's LINE_NUMBER_KEY key.
"""
parsed = ast.parse(self.content, self.path)

examples = None
for node in parsed.body:
if isinstance(node, ast.Assign):
for target in node.targets:
if isinstance(target, ast.Name) and target.id == "EXAMPLES" and isinstance(node.value, ast.Constant):
examples = node.value.value

docs = read_docstring(str(self.path))
examples = docs["plainexamples"]
return examples or ""

@property
Expand Down

0 comments on commit f64c4c1

Please sign in to comment.