Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ShigureLab/codespan-reporting-py

Repository files navigation

codespan-reporting-py

A python binding for codespan-reporting

PyPI - Python Version pypi PyPI - Downloads LICENSE
ruff Gitmoji

Installation

pip install codespan-reporting

Usage

import textwrap
from codespan_reporting import (
 Config,
 Diagnostic,
 Label,
 SimpleFiles,
 StandardStream,
 emit,
)
files = SimpleFiles()
file_id = files.add(
 "FizzBuzz.fun",
 textwrap.dedent(
 """\
 module FizzBuzz where

 fizz1 : Nat → String
 fizz1 num = case (mod num 5) (mod num 3) of
 0 0 => "FizzBuzz"
 0 _ => "Fizz"
 _ 0 => "Buzz"
 _ _ => num

 fizz2 : Nat → String
 fizz2 num =
 case (mod num 5) (mod num 3) of
 0 0 => "FizzBuzz"
 0 _ => "Fizz"
 _ 0 => "Buzz"
 _ _ => num
 """,
 ),
)
diagnostic = Diagnostic.error(
 "E0308",
 "`case` clauses have incompatible types",
 [
 Label.primary(file_id, 328, 331, "expected `String`, found `Nat`"),
 Label.secondary(file_id, 211, 331, "`case` clauses have incompatible types"),
 Label.secondary(file_id, 258, 268, "this is found to be of type `String`"),
 Label.secondary(file_id, 284, 290, "this is found to be of type `String`"),
 Label.secondary(file_id, 306, 312, "this is found to be of type `String`"),
 Label.secondary(file_id, 186, 192, "expected type `String` found here"),
 ],
 [
 textwrap.dedent(
 """\
 expected type `String`
 found type `Nat`
 """,
 )
 ],
)
writer = StandardStream.Stderr
config = Config()
emit(writer, config, files, diagnostic)

About

A python binding for codespan-reporting

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

AltStyle によって変換されたページ (->オリジナル) /