Skip to content
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

tests: Change tests/runtest.py to match the pylint code style #1810

Merged
merged 4 commits into from
Sep 6, 2023

Conversation

sypark9646
Copy link
Contributor

@sypark9646 sypark9646 commented Aug 28, 2023

apply black for linting, and follow common rules in python code.
The following warnings from pylint are fixed.

If you want to find the full pylint warning, run the following command:

pylint tests/runtest.py 

And if you want to find a specific pylint warning(ex. W0613), you can run a command like this:

pylint tests/runtest.py --disable R,C,W,E --enable W0613

resolves #1497
related #1396

@honggyukim
Copy link
Collaborator

Thanks, but it looks too many changes are applied in a single patch. Is it possible to apply each pylint violation one at a single commit then create multiple commits?

@honggyukim
Copy link
Collaborator

Simply speaking, it's very difficult to review if a single change contains too many different changes.

@sypark9646
Copy link
Contributor Author

Oh I get it.
I'll split and re-commit as per warning, thanks!

@namhyung
Copy link
Owner

Can you please change the max line length from 80 to 100?

@sypark9646
Copy link
Contributor Author

Okay, I'll incorporate your suggestion into the code! Thanks

changed the max line length from 80 to 100

Signed-off-by: Soyeon Park <[email protected]>
If you want to catch all exceptions that signal program errors, use ``except Exception:``

Signed-off-by: Soyeon Park <[email protected]>
Used when a variable is defined but not used.

Signed-off-by: Soyeon Park <[email protected]>
Though there are unusual situations where these give different results.

Signed-off-by: Soyeon Park <[email protected]>
@sypark9646
Copy link
Contributor Author

sypark9646 commented Sep 4, 2023

The pylint warning you mentioned is left W0613 (unused-argument),
If you need a commit to delete ignored arguments used in simple_sort, report_sort, graph_sort, dump_sort, chrome_sort, etc. I'd delete that, but I'm afraid it might be important, so I couldn't delete it now.

Copy link
Owner

@namhyung namhyung left a comment

Choose a reason for hiding this comment

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

LGTM, and it'd be nice if you could share the exact command line you ran to get these warnings.

@namhyung
Copy link
Owner

namhyung commented Sep 6, 2023

Oh, you already wrote the command line in the PR. I'll merge the change then.

@namhyung namhyung merged commit e5f6cde into namhyung:master Sep 6, 2023
@sypark9646 sypark9646 deleted the style/pylint-style branch September 6, 2023 06:14
@namhyung
Copy link
Owner

Ugh, please put a blank line after the subject line later so that git log --oneline can show it properly.

I hate github displaying such a subject line without any warnings.

@honggyukim
Copy link
Collaborator

@sypark9646, You will understand what @namhyung mentioned by running git log and git log --oneline.

The commit message should have a separate commit title, which is written in a single line at the top.

For example, the your commit message is written as follows.

commit 8d8f168b1b57ab1de1a8f7a6b0404da6d7b0053e
Author:     Soyeon Park <[email protected]>
AuthorDate: Mon Sep 4 12:44:32 2023 +0900

    Pylint W0612: Unused variable
    Used when a variable is defined but not used.
    
    Signed-off-by: Soyeon Park <[email protected]>

But it should have a separate commit title in a single line. Because of this, the git log --oneline output looks weird.

$ git log --oneline 8d8f168b -1
8d8f168b Pylint W0612: Unused variable Used when a variable is defined but not used.

So the commit message should be changed with an empty line as follows.

commit 8d8f168b1b57ab1de1a8f7a6b0404da6d7b0053e
Author:     Soyeon Park <[email protected]>
AuthorDate: Mon Sep 4 12:44:32 2023 +0900

    tests: Pylint W0612: Unused variable

    Used when a variable is defined but not used.
    
    Signed-off-by: Soyeon Park <[email protected]>

It will show the commit log with --oneline properly as follows.

$ git log --oneline 8d8f168b -1
8d8f168b tests: Pylint W0612: Unused variable

This PR is already merged so we can't change it, but please keep that in mind for the next PR. Thanks.

@MichelleJin12
Copy link
Contributor

MichelleJin12 commented Sep 13, 2023

Hello, @sypark9646,

In addition to Honggyu's comment,
You don't need to add . to the end of the title of the commit message.

Thank you for your contribution. :D

@sypark9646
Copy link
Contributor Author

sypark9646 commented Sep 14, 2023

Ah, thank you. I'll make sure to keep that in mind next time!!

@namhyung
Copy link
Owner

Is there any checker doing this automatically?

@honggyukim
Copy link
Collaborator

There is https://github.com/conventional-changelog/commitlint but I haven’t had a chance to add it in our pre-commit hook yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

warnings in pylint tests/runtest.py
4 participants