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

Fix pylint problems #12912

Open
7 of 9 tasks
vojtechjelinek opened this issue May 25, 2021 · 134 comments
Open
7 of 9 tasks

Fix pylint problems #12912

vojtechjelinek opened this issue May 25, 2021 · 134 comments
Labels
enhancement Label to indicate an issue is a feature/improvement good first issue Impact: Medium Will improve quality-of-life for at least 30% of users. Work: Low Solution is known and broken into good-first-issue-sized chunks.

Comments

@vojtechjelinek
Copy link
Member

vojtechjelinek commented May 25, 2021

The goal of this issue is to enable some pylint rules that we disabled while doing the Python 3 migration.

Steps to follow to create a PR:

  1. Ask @seanlip to assign you to one of the items below
  2. Remove the assigned item from the .pylintrc
  3. Run python -m scripts.linters.run_lint_checks --only-check-file-extensions=py --path=core --verbose to check existing issues in the codebase. (This can take 3-5 mins mins to complete.)
  4. If the above script takes too much time or you have a slow machine then consider pushing the code to GitHub and GitHub actions will run these checks for you.
  5. Fix all the issues found by running the above command.
  6. Commit all the changes and create a PR.

Example PRs: #14474

Remove some disables from the .pylintrc:

Refactor custom validators that are not working correctly:

Decided not to introduce:

  • consider-using-dict-items @mjsumpter
  • consider-using-f-string
  • super-with-arguments @jrvald
  • unnecessary-pass
  • arguments-renamed
  • import-outside-toplevel
@dushyantbhardwaj9
Copy link

Hey @vojtechjelinek, Is this still open?

@vojtechjelinek
Copy link
Member Author

@dushyantbhardwaj9 Yes

@Manan-Rathi
Copy link
Contributor

Manan-Rathi commented Dec 28, 2021

Hi @vojtechjelinek! Could you kindly assign me no-else-continue and no-else-raise?

@DubeySandeep
Copy link
Member

Hi @Manan-Rathi, I've assigned you to no-else-continue and no-else-raise!

@Manan-Rathi
Copy link
Contributor

Hi @Manan-Rathi, I've assigned you to no-else-continue and no-else-raise!

Should I create two separate PRs or just one?

@DubeySandeep
Copy link
Member

@Manan-Rathi Create one PR with all the changes i.e, enabling both the rules and fixing existing lint issues in the codebase. (Considering the number of changed files in the PR won't be > 50)

@IamEzio
Copy link
Contributor

IamEzio commented Dec 28, 2021

Hi @vojtechjelinek @DubeySandeep ! Can I be assigned to deprecated-method ?

@DubeySandeep
Copy link
Member

@IamEzio I've assigned you to deprecated-method!

@IamEzio
Copy link
Contributor

IamEzio commented Dec 29, 2021

Hey @DubeySandeep Can I also work on consider-using-in ?

@rohittiwari761
Copy link

Hey @vojtechjelinek Can you please assign me unnecessary-pass?

@vojtechjelinek
Copy link
Member Author

@rohittiwari761 Hey, can you send the errors that show up when you enable unnecessary-pass? I just realized that we might not want to enable this one.

@vojtechjelinek
Copy link
Member Author

@IamEzio Done.

@Manan-Rathi
Copy link
Contributor

Hi @vojtechjelinek. Kindly assign me useless-object-inheritance.

@raghavluthra20
Copy link

Hey @vojtechjelinek Can I work on consider-using-f-string?

@vojtechjelinek
Copy link
Member Author

@raghavluthra20 Please wait a bit as f-strings are not used in our codebase and I need to check with the rest of the core maintainers. Feel free to pick different rule for now.

@Dhruv454000
Copy link

hi @vojtechjelinek can i be assigned to super-with-arguments

@vojtechjelinek
Copy link
Member Author

@Dhruv454000 Done.

vojtechjelinek pushed a commit that referenced this issue Jan 17, 2022
@PietroFracCab
Copy link

@PietroFracCab Are you still working on the cyclic-imports?

Yes. I was out in vacation. should be done until next week.

@U8NWXD
Copy link
Member

U8NWXD commented Mar 16, 2023

De-assigning @richard-johansson @PietroFracCab due to inactivity. Please let me know if you're still working on this!

@rahulsurwade08
Copy link

Hey @vojtechjelinek @U8NWXD I would love to work on this issue. How can I get started?

@U8NWXD
Copy link
Member

U8NWXD commented Mar 17, 2023

@rahulsurwade08 see the instructions at the top of this issue. If you still have questions, please be more specific about what you find confusing

@josieecook
Copy link

@U8NWXD Hello! Could I please be assigned to cyclic-import? Thank you!

@Priyansh61
Copy link
Contributor

Hi! @josieecook Per the guidance at https://github.com/oppia/oppia/wiki/Contributing-code-to-Oppia#choosing-a-good-first-issue, please provide an explanation of what your PR will do (with names of files you're changing, what you plan to change in each file, etc.). If it looks good, we can assign you to this issue.

@anjaist
Copy link

anjaist commented Apr 20, 2023

Hello @U8NWXD, I'd like to be assigned consider-using-with.
Here are the files that would be affected:

core/controllers/profile_test.py
core/controllers/editor_test.py
core/domain/exp_services_test.py

Example change:
before:

zf_saved = zipfile.ZipFile(io.BytesIO(data.body))
assert zf_saved[...]

after:

with zipfile.ZipFile(io.BytesIO(data.body)) as zf_saved:
    assert zs_saved[...]

Additionally, I'd add a single # pylint: disable=consider-using-with line here, as the usage of this function is always using a with statement and we do only casting here. I'm not sure if there is an alternative way of doing this apart from changing the way this utils.open_file func is used.

@adityauwu
Copy link

adityauwu commented Jan 13, 2024

Hi @vojtechjelinek ,
M new to open source and I have tried to disable from the .pylintrc : cyclic-import

Steps):

  1. Removed the cyclic-import from the .pylintrc file
    2)Ran python -m scripts.linters.pre_commit_linter --only-check-file-extensions=py --path=core --verbose to check
    3)Passed without any errors

Please refer the attached below:

Image

@seanlip
Copy link
Member

seanlip commented Jan 13, 2024

@adityauwu You're welcome to work on this if you like. Do you want to be assigned? If so, please say that explicitly next time. Also please ensure you've followed all the guidance at https://github.com/oppia/oppia/wiki/Contributing-code-to-Oppia bedore opening a PR. Thanks!

@adityauwu
Copy link

Hi @seanlip , Yes please assign it to me, I have created a PR please review and guide me through the same! Thanks

@m0nax5
Copy link

m0nax5 commented Apr 2, 2024

Hi @seanlip ! I would have liked to be assigned consider-using-with so I tried following the steps you gave to create a PR but I ran into an issue.

  • I removed consider-using-with from the .pylintrc
  • I tried running python -m scripts.linters.pre_commit_linter --only-check-file-extensions=py --path=core --verbose but I faced the following error /usr/bin/python: No module named scripts.linters.pre_commit_linter
  • So I checked my code base and there is no pre_commit_linter directory inside scripts/linters/

I there anything that has changed in the code base since your original post ? Has it anything to do with the scripts/pre_commit_hook_test.py file ? Should I run another command to check for issues ?
Thanks for your help !

@seanlip
Copy link
Member

seanlip commented Apr 3, 2024

@m0nax5 I think pre_commit_linter got renamed to run_lint_checks. See https://github.com/oppia/oppia/wiki/Lint-Checks. I've updated the issue description accordingly, thanks for raising this.

Also deassigning @adityauwu due to lack of activity.

@m0nax5
Copy link

m0nax5 commented Apr 6, 2024

@seanlip thanks I was able to run the linter checks ! But I also had to manually install esprima by running pip install esprima for it to work. Maybe it should be added to the dependencies installed during the initial installation of the Oppia repository ?

Also could you please assign me consider-using-with ? My code is ready to create a PR. Thanks !

@seanlip
Copy link
Member

seanlip commented Apr 9, 2024

Thanks @m0nax5, I've assigned you. Could you please file an issue about the dependency issue you mentioned and steps to reproduce it on our wiki repo: github.com/oppia/oppia-web-developer-docs -- as well as your suggested fix? Thanks!

@m0nax5
Copy link

m0nax5 commented Apr 13, 2024

I won’t be filing an issue since I wasn’t able to reproduce the bug, even though I tried on another machine. I checked and the dependency I was missing was supposed to have been installed since it is in requirements_dev.in in line 9 : esprima==4.0.1, and 4.0.1 is the same version that I had to download manually. The same happened to me later with other libraries so I guess something just went wrong during the installation process on my machine.

@seanlip seanlip added Impact: Medium Will improve quality-of-life for at least 30% of users. and removed Impact: Low -- ONLY DO IF GOOD FIRST ISSUE Postponing for now, since it doesn't affect users much. labels Apr 17, 2024
@Felix-Mauyon
Copy link
Contributor

Hi @seanlip

I ran this: python -m scripts.linters.run_lint_checks --only-check-file-extensions=py --path=core --verbose
And it showed this

Does this mean this issue has been fixed?

Screenshot 2024-05-07 195419

@m0nax5
Copy link

m0nax5 commented May 8, 2024

Hi @Felix-Mauyon ! If I may, did you chose an item to remove from the .pylintrc file like mentioned in step 2 ? If not it's normal that the checks should all pass : it's only when you remove one of the mentioned lines that a lint check is added, which may then bring about new failures (the ones that this issue aims to fix). Hope this helps !

@seanlip
Copy link
Member

seanlip commented May 8, 2024

Confirming @m0nax5's explanation is spot-on (thanks @m0nax5)!

@Felix-Mauyon
Copy link
Contributor

Thanks @m0nax5

If I understand you well, I am supposed to choose one of the item from step 2 and remove that line from the .pylintrc and rerun this:

python -m scripts.linters.run_lint_checks --only-check-file-extensions=py --path=core --verbose in the hope of getting a new failure. Is the failure a confirmation that it worked or I am supposed to do something about the failure as well?

@Victor-ID
Copy link

Hi @seanlip, can I be assigned to fix the consider-using-with rule?

@seanlip
Copy link
Member

seanlip commented May 22, 2024

@Victor-ID I think @m0nax5 is working on this, but that PR has been stagnant for a while.

@m0nax5 are you working on this still, or would you like someone else to take it up?
@Victor-ID There is a PR open in #20134 that seems blocked. Can you help figure out what the issue is? If so then you might be able to take this up or collaborate with @m0nax5 on getting that PR merged.

Thanks!

@m0nax5
Copy link

m0nax5 commented May 23, 2024

Hi @seanlip, I've been stuck on that issue for a while now and I haven't had as much time to work on it, it would be great if @Victor-ID could have a look at it, and even take it up if he would like to. Also if @Victor-ID you find a solution to it and would like me to help with the code I've submitted we could collaborate on it too, whichever way you prefer is fine by me !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Label to indicate an issue is a feature/improvement good first issue Impact: Medium Will improve quality-of-life for at least 30% of users. Work: Low Solution is known and broken into good-first-issue-sized chunks.
Projects
Status: Todo
Development

No branches or pull requests