MCPcopy Index your code
hub / github.com/saltstack/salt / annotate

Function annotate

tools/precommit/docstrings.py:803–831  ·  view source on GitHub ↗
(
    ctx: Context,
    kind: str,
    fpath: pathlib.Path,
    start_lineno: int,
    end_lineno: int,
    message: str,
)

Source from the content-addressed store, hash-verified

801
802
803def annotate(
804 ctx: Context,
805 kind: str,
806 fpath: pathlib.Path,
807 start_lineno: int,
808 end_lineno: int,
809 message: str,
810) -> None:
811 if kind not in ("warning", "error"):
812 raise RuntimeError("The annotation kind can only be one of 'warning', 'error'.")
813 if os.environ.get("GH_ACTIONS_ANNOTATE") is None:
814 return
815
816 github_output = os.environ.get("GITHUB_OUTPUT")
817 if github_output is None:
818 ctx.warn("The 'GITHUB_OUTPUT' variable is not set. Not adding annotations.")
819 return
820
821 if TYPE_CHECKING:
822 assert github_output is not None
823
824 message = (
825 message.rstrip().replace("%", "%25").replace("\r", "%0D").replace("\n", "%0A")
826 )
827 # Print it to stdout so that the GitHub runner pick's it up and adds the annotation
828 ctx.print(
829 f"::{kind} file={fpath},line={start_lineno},endLine={end_lineno}::{message}",
830 soft_wrap=True,
831 )
832
833
834@cgroup.command(

Callers 2

check_docstringsFunction · 0.85
check_cp1252_docstringsFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected