Skip to main content

Notify Mypy output via GitHub Workflow Commands

Project description

Code style: black Imports: isort PyPI pyversions

mypy-gh-action-report

Notify Mypy output via GitHub Workflow Commands

Installation

pip install mypy-gh-action-report

Usage

mypy . | mypy-gh-action-report

or, to generate JSON output

mypy . | mypy-gh-action-report --json-only

Output

For the following Mypy output:

mypy_gh_action_report/types.py:3: error: "list" expects 1 type argument, but 2 given  [type-arg]
mypy_gh_action_report/models.py:13: error: Function is missing a return type annotation  [no-untyped-def]
mypy_gh_action_report/parser.py:46: error: Item "None" of "Optional[MypyError]" has no attribute "file_name"  [union-attr]
mypy_gh_action_report/parser.py:48: error: Item "None" of "Optional[MypyError]" has no attribute "line_no"  [union-attr]
mypy_gh_action_report/main.py:16: error: Argument "mypy_output" to "handle_output" has incompatible type "Optional[str]"; expected "str"  [arg-type]
Found 8 errors in 4 files (checked 7 source files)

mypy-gh-action-report will generate:

::warning title=,file=mypy_gh_action_report/types.py,line=3,endLine=,col=,endColumn=::"list" expects 1 type argument, but 2 given
::warning title=,file=mypy_gh_action_report/models.py,line=13,endLine=,col=,endColumn=::Function is missing a return type annotation
::warning title=,file=mypy_gh_action_report/parser.py,line=46,endLine=,col=,endColumn=::Item "None" of "Optional[MypyError]" has no attribute "file_name"
::warning title=,file=mypy_gh_action_report/parser.py,line=48,endLine=,col=,endColumn=::Item "None" of "Optional[MypyError]" has no attribute "line_no"
::warning title=,file=mypy_gh_action_report/main.py,line=16,endLine=,col=,endColumn=::Argument "mypy_output" to "handle_output" has incompatible type "Optional[str]"; expected "str"

with --json-only flag:

{
  "mypy_gh_action_report/types.py": [
    {
      "line_no": 3,
      "error_code": "type-arg",
      "type": "error",
      "message": "\"list\" expects 1 type argument, but 2 given"
    }
  ],
  "mypy_gh_action_report/models.py": [
    {
      "line_no": 13,
      "error_code": "no-untyped-def",
      "type": "error",
      "message": "Function is missing a return type annotation"
    }
  ],
  "mypy_gh_action_report/parser.py": [
    {
      "line_no": 46,
      "error_code": "union-attr",
      "type": "error",
      "message": "Item \"None\" of \"Optional[MypyError]\" has no attribute \"file_name\""
    },
    {
      "line_no": 48,
      "error_code": "union-attr",
      "type": "error",
      "message": "Item \"None\" of \"Optional[MypyError]\" has no attribute \"line_no\""
    }
  ],
  "mypy_gh_action_report/main.py": [
    {
      "line_no": 16,
      "error_code": "arg-type",
      "type": "error",
      "message": "Argument \"mypy_output\" to \"handle_output\" has incompatible type \"Optional[str]\"; expected \"str\""
    }
  ]
}

Development

In order to contribute to this project you need to have poetry installed.

In order to run tests issue:

poetry install
poetry run pytest .

Exit codes

Following Scenarios are covered:

Description Mypy exit code mypy-gh-action-report exit code
Success 0 0
Issues found 1 1
Mypy errors 2 2

TODO

  1. Group warnings for the same line

Thanks

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mypy_gh_action_report-0.1.0.tar.gz (5.4 kB view hashes)

Uploaded Source

Built Distribution

mypy_gh_action_report-0.1.0-py3-none-any.whl (6.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page