Skip to content

Conversation

@crazybolillo
Copy link
Contributor

Type of Changes

Type
✨ New feature

Description

A new github reporter has been added. This reporter automatically annotates code on GitHub's UI with the messages found during linting.

Closes #9443.

@codecov
Copy link

codecov bot commented Mar 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.83%. Comparing base (6a09d29) to head (2c76860).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #9484   +/-   ##
=======================================
  Coverage   95.82%   95.83%           
=======================================
  Files         173      173           
  Lines       18797    18808   +11     
=======================================
+ Hits        18012    18024   +12     
+ Misses        785      784    -1     
Files Coverage Δ
pylint/reporters/text.py 94.89% <100.00%> (+0.44%) ⬆️

... and 1 file with indirect coverage changes

@github-actions

This comment has been minimized.

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's pretty clean. Let's also use it for ourselves :D (before fixing the 'typo' so it's easy to test ?)

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@crazybolillo
Copy link
Contributor Author

I have this dummy PR which I am constantly updating with the HEAD of this PR. It shows both error, warning and notice annotations being generated by pylint's output: https://github.com/zoftko/balba/pull/2/files

@github-actions

This comment has been minimized.

A new `github` reporter has been added. This reporter automatically
annotates code on GitHub's UI with the messages found during linting.

Closes pylint-dev#9443.
@github-actions

This comment has been minimized.

Copy link
Collaborator

@DanielNoord DanielNoord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks almost done already! Thanks very much!

types: [python]
args: ["-rn", "-sn", "--rcfile=pylintrc", "--fail-on=I"]
args:
["-rn", "-sn", "--rcfile=pylintrc", "--fail-on=I", "--output-format=github"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this doesn't do much right? As pre-commit isn't uploaded to Github.

Instead we should use this in our workflows defined in .github

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you are right, it is only needed for the manual stage hook which is run in the checks.yml workflow.

Comment on lines 1 to 2
A new `github` reporter has been added. This reporter automatically annotates code on GitHub's user interface
with the messages found during linting. Use it with `pylint --output-format=github`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A new `github` reporter has been added. This reporter automatically annotates code on GitHub's user interface
with the messages found during linting. Use it with `pylint --output-format=github`.
A new `github` reporter has been added. This reporter returns the output of `pylint` in the format that
Github can use to automatically annotate code. Use it with `pylint --output-format=github`.

Users will still need to run the linter in the right workflow so it is not fully automatic.

TextReporter(StringIO()),
ColorizedTextReporter(StringIO()),
JSON2Reporter(StringIO()),
GithubReporter(StringIO()),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we would also test the output of this reporter, but I would be fine with not doing so for now as it is such a nice to have feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was thinking about tests but since Github is the one that will annotate after all, seems like we just need to trust on Github 🤔

@Pierre-Sassoulas
Copy link
Member

Changes look great, but I can't see the result either hère or on the PR you linked (maybe because I'm on mobile?).

@crazybolillo
Copy link
Contributor Author

Changes look great, but I can't see the result either hère or on the PR you linked (maybe because I'm on mobile?).

I checked on the app (mobile) and I can't see the annotations either so it seems like it is not supported. There are no annotations anymore in this PR, but the dummy one I linked still has them (just checked on a PC).

Used message.C directly instead of slicing again, improved feature notes
and removed unecessary output from locally run pre-commit pylint hook.
It was kept for the manual stage since that is run on Github and needs
it to annotate code on PRs.
@Pierre-Sassoulas
Copy link
Member

It's a pity but not a blocker maybe github will evolve to show them on mobile later. (And jobs will show violations like before). I will be able to finish the review in one to three weeks, sorry for that.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2024

🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉

This comment was generated for commit 2c76860

@crazybolillo crazybolillo requested a review from DanielNoord March 7, 2024 14:16
Copy link
Collaborator

@DanielNoord DanielNoord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!!

@Pierre-Sassoulas Would you be okay with me merging this? I only need to apply the correct labels I think!

@DanielNoord DanielNoord added the Enhancement ✨ Improvement to a component label Mar 7, 2024
@Pierre-Sassoulas
Copy link
Member

Sure @DanielNoord if you can see the result and think it looks good then please do. As I said the code itself and the design are great. Love the brevity @crazybolillo, great MR

@DanielNoord DanielNoord merged commit f33b822 into pylint-dev:main Mar 8, 2024
@crazybolillo crazybolillo deleted the i9443-crazybolillo branch March 9, 2024 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement ✨ Improvement to a component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GitHub actions output format

3 participants