jordemort / action-pyright

A GitHub Action to run pyright
MIT License
11 stars 6 forks source link

pyright_to_rdjson.py - KeyError: 'rule' #13

Closed chadsr closed 2 years ago

chadsr commented 2 years ago

Hi, I was hoping to test out this action, but there seems to be an issue in pyright_to_rdjson.py regarding a KeyError. I'm guessing the output format from pyright has changed slightly?

I may find the time in the next week or so to look into it, but if you already know how to solve it, some help/input would be appreciated!

Example stacktrace:

  Searching for source files
  Found 10 source files
  Traceback (most recent call last):
    File "/home/runner/work/_actions/jordemort/action-pyright/v1/pyright_to_rdjson.py", line 44, in <module>
      print(pyright_to_rdjson(sys.stdin))
    File "/home/runner/work/_actions/jordemort/action-pyright/v1/pyright_to_rdjson.py", line 22, in pyright_to_rdjson
      "message": f"{d['message']} ({d['rule']})",
  KeyError: 'rule'
  reviewdog: parse error: failed to unmarshal rdjson (DiagnosticResult): proto: syntax error (line 1:1): unexpected token 
jordemort commented 2 years ago

I haven't run into this myself, but I saw in a fork that someone else made that they had made the rule key optional:

https://github.com/solarmonkey/action-pyright/commit/ccf5d122dec7f83f27e1c78e803f49e40dab553d

I'll cherry-pick that commit over here for you a bit later, unless you or @solarmonkey want to make a PR here before I get to it :)

chadsr commented 2 years ago

I haven't run into this myself, but I saw in a fork that someone else made that they had made the rule key optional:

solarmonkey@ccf5d12

I'll cherry-pick that commit over here for you a bit later, unless you or @solarmonkey want to make a PR here before I get to it :)

Ah, great! Since there was no response from @solarmonkey yet, then i'm happy to just PR the one-liner without the need to cherry pick. (Unless you'd prefer to do it that way)

Also for reference: https://github.com/microsoft/pyright/issues/2634