Skip to content

change pylint error codes to messages #2700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Piraty
Copy link
Contributor

@Piraty Piraty commented Oct 5, 2021

Checklist for PRs

  • Added .. versionadded:: version, .. versionchanged:: version or .. deprecated:: version to the docstrings for user facing changes (for methods/class descriptions, arguments and attributes)
  • Created new or adapted existing unit tests
  • Added myself alphabetically to AUTHORS.rst (optional)

Closes #2664

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Hey there. Relax, I am just a little warning for the maintainers to release directly after merging your PR, otherwise we have broken examples and people might get confused :)

@Piraty Piraty force-pushed the pylint-error-codes-to-message branch 2 times, most recently from af0cf58 to 0fb012d Compare October 5, 2021 20:51
Copy link
Member

@Bibo-Joshi Bibo-Joshi left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! The changes mostly look good :)
At a few places, the pylint comments went to another line (probably because the line became too long), so that the comment is now no longer at the line where pylint emits the warning. This is the reason that the tests fail. If you run pre-commit run -a in your command line, then it will show you all the places were the comments need to be moved :) The contribution guide also has some details about pre-commit.

@harshil21 harshil21 added this to the v14 milestone Oct 6, 2021
@harshil21 harshil21 added the ⚙️ documentation affected functionality: documentation label Oct 6, 2021
@Piraty Piraty force-pushed the pylint-error-codes-to-message branch from 0fb012d to b77a2ba Compare October 6, 2021 20:42
@Piraty
Copy link
Contributor Author

Piraty commented Oct 6, 2021

thanks for feedback.i ran pre-commit run -a. pylint is happy now

note that the mypy-ptb suited failed before as well, reporting on lines i didn't touch.

telegram/request.py:46: error: unused 'type: ignore' comment
telegram/request.py:47: error: unused 'type: ignore' comment
telegram/request.py:48: error: unused 'type: ignore' comment
telegram/request.py:49: error: unused 'type: ignore' comment
telegram/request.py:50: error: unused 'type: ignore' comment
telegram/request.py:91: error: unused 'type: ignore' comment
telegram/request.py:173: error: unused 'type: ignore' comment
telegram/request.py:205: error: unused 'type: ignore' comment

@Bibo-Joshi
Copy link
Member

Thanks for the updates! I'm not sure why mypy complains about request.py for you locally. in the automated tests it's just complaining about:

telegram/bot.py:198: error: Function is missing a type annotation  [no-untyped-def]
telegram/bot.py:199: error: unused 'type: ignore' comment
Found 2 errors in 1 file (checked 147 source files)

🤔 So if you could fix that last one and the automated tests pass, then I'm happe 😄

@Piraty
Copy link
Contributor Author

Piraty commented Oct 6, 2021

FTR: I ran this and got a substantially different report from mypy than CI (posted above)

python3 --version # Python 3.9.7
rm -rf venv
python3 -m venv venv
. ./venv/bin/activate
python3 -m pip install -r requirements-dev.txt -r requirements.txt
pre-commit run -a

@Piraty Piraty force-pushed the pylint-error-codes-to-message branch 3 times, most recently from b69f53e to 064c2fd Compare October 6, 2021 22:32
@Piraty Piraty requested a review from Bibo-Joshi October 6, 2021 22:38
Copy link
Member

@Bibo-Joshi Bibo-Joshi left a comment

Choose a reason for hiding this comment

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

Thanks for the updates :) Strange about mypy …
I left one nitpick below. In addition, up to now I had forgotten about the second part of #2664, namely doing the same for flake8, which are the # noqa comments. I should have written that in the description of the issue as well … If you would like to tackle those as well, I'd be glad. Otherwise that can be done in another PR.

PS: Please don't force push on PRs if possible - makes it harder to keep track of changes during the review process and we squash-merge anyway :)

Piraty added 2 commits October 7, 2021 23:07
* use a map of pylint codes -> messages to replace all occurences,
  see below script
* format with black
* fix broken ignore rules after black added line breaks

Closes: python-telegram-bot#2664

    #!/bin/sh -e

    check() { grep -E -r -e '#.*pylint.*disable.*=[CW]+[0-9]+' | wc -l ;}

    check

    src_files="$(git ls-files '*.py')"
    pylint --list-msgs |
	    grep '^:' |
	    cut -d: -f2 |
	    sed -e 's/(//g' -e 's/)//g' \
		    >/tmp/pylint-map-codes-to-msg

    while read -r msg code; do
	    echo "checking code: $code"
	    sed \
		    -e "s/${code}$/$msg/" \
		    -e "s/${code},/${msg}, /" \
		    -i $src_files
	    # double-check ;)
	    grep -e "$code" $src_files && echo 'OH NO!!'
    done </tmp/pylint-map-codes-to-msg

    check
@Piraty Piraty force-pushed the pylint-error-codes-to-message branch from 064c2fd to 437e03b Compare October 7, 2021 21:17
@Piraty
Copy link
Contributor Author

Piraty commented Oct 7, 2021

I couldn't find flake8 code's in-source string equivalents... ?
i'll rather use a second PR
PS: if you want new contributors to know you're squashing their commits anyway, line it out in CONTRIBUTING

@Bibo-Joshi
Copy link
Member

flake8 comments can be found e.g. here

from telegram.ext import CallbackContext # noqa: F401

But, okay, let's make it a second PR.

PS: if you want new contributors to know you're squashing their commits anyway, line it out in CONTRIBUTING

Fair point. Would you like to PR for that yourself (based on v14)?

@Bibo-Joshi Bibo-Joshi merged commit 01be85f into python-telegram-bot:v14 Oct 8, 2021
@Piraty
Copy link
Contributor Author

Piraty commented Oct 8, 2021

thanks for merging, glad to help.

you misunderstood; i know how to find # noqa string in code (duh) but flake8 doesn't seem to have string-messages that can be used instead of their error codes

@Bibo-Joshi
Copy link
Member

mh, you are right. I don't know where exactly I got the idea from that this should be possible for flake8 as well, but it's indeed not. Thanks for the clarification :)

Bibo-Joshi added a commit that referenced this pull request Oct 9, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Oct 10, 2021
@harshil21 harshil21 added the hacktoberfest-accepted other: hacktoberfest-accepted label Oct 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
⚙️ documentation affected functionality: documentation hacktoberfest-accepted other: hacktoberfest-accepted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy