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

Removed unused imports from files #3906

Merged

Conversation

SaravgiYash
Copy link
Contributor

@SaravgiYash SaravgiYash commented Oct 8, 2020

Related to #3483

refactor removed unused imports will commit 2 files at a time

Technical

Testing

Screenshot

Stakeholders

@cclauss @imskr

@cclauss
Copy link
Contributor

cclauss commented Oct 8, 2020

Modified commit message because this PR would not get rid of ALL unused imports so #3483 should remain open even if this PR lands.

@SaravgiYash
Copy link
Contributor Author

SaravgiYash commented Oct 8, 2020

@cclauss I have removed unused imports till .\openlibrary\plugins\openlibrary\utils.py so should I add them here 2 at a time? or create separate PR for each of them?

@SaravgiYash
Copy link
Contributor Author

SaravgiYash commented Oct 8, 2020

@cclauss Travis CI seems unhappy with batch 7/8/9/10

@cclauss
Copy link
Contributor

cclauss commented Oct 11, 2020

@SaravgiYash
Copy link
Contributor Author

SaravgiYash commented Oct 11, 2020

@cclauss can you help me with what all changes do I need to make. It says the line is too long but I actually removed a word so I am a little clueless here.
I am sorry for any inconvenience I may have caused you.
Edit: Should I change max line length to 113 or add that import back ?

@cclauss
Copy link
Contributor

cclauss commented Oct 11, 2020

Once you change a line, then that line must comply with strict flake8 --max-line-length=88 for the tests to pass. This means that you need to wrap that line so that it is no longer than 88 characters max. Changing max-line-length to 113 is not acceptable.

@@ -2,7 +2,7 @@

from openlibrary.catalog.marc.get_subjects import subjects_for_work
from openlibrary.catalog.marc.marc_base import BadMARC, NoTitle, MarcException
from openlibrary.catalog.utils import pick_first_date, tidy_isbn, flip_name, remove_trailing_dot, remove_trailing_number_dot
from openlibrary.catalog.utils import pick_first_date, tidy_isbn, remove_trailing_dot, remove_trailing_number_dot
Copy link
Contributor

@cclauss cclauss Oct 11, 2020

Choose a reason for hiding this comment

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

Suggested change
from openlibrary.catalog.utils import pick_first_date, tidy_isbn, remove_trailing_dot, remove_trailing_number_dot
from openlibrary.catalog.utils import (
pick_first_date, remove_trailing_dot, remove_trailing_number_dot, tidy_isbn
)

@SaravgiYash SaravgiYash force-pushed the 3483/refactor/removed-unused-imports branch from 3683202 to 4258733 Compare October 11, 2020 11:35
@SaravgiYash
Copy link
Contributor Author

@cclauss I have done the required changes and added some new commits. Status check is missing from initial 6 commits so did I do something wrong?

@cclauss
Copy link
Contributor

cclauss commented Oct 11, 2020

I still have concerns about #3483 (comment)

@SaravgiYash
Copy link
Contributor Author

SaravgiYash commented Oct 11, 2020

@cclauss so should I create a PR for each commit separately. But if the build is successful then there shouldn't be any problem??

@cclauss
Copy link
Contributor

cclauss commented Oct 11, 2020

If the build is successful then there shouldn't be any problem??

For that, the integration tests would need to be running #3682 and probably added to significantly.

Can you please create a subset of this PR that only removes Python standard library imports? That should be safer and once that lands, we can rebase this PR on master and land the non-standard library changes.

@SaravgiYash
Copy link
Contributor Author

@cclauss Is there a way I can automatically check for only python standard library unused imports, or do I have to do that manually?

@cclauss
Copy link
Contributor

cclauss commented Oct 11, 2020

Manual I believe. Do you use git on the command-line?

@SaravgiYash
Copy link
Contributor Author

Manual I believe. Do you use git on the command-line?

@cclauss Yes
I have created a new PR #3909 in which I have removed all python standard library unused imports till batch13

@mekarpeles
Copy link
Member

@Yashs911 I'd strongly suggest breaking this PR into a few smaller PRs so we can help you merge them much more quickly :)

Some of these changes are very straight forward (like the unused standard libraries: simplejson, re etc.)

Some of the Open Library specific imports may have strange side effects which needs to be tested (I am not sure I blindly trust the linter in these cases)

@mekarpeles
Copy link
Member

Thank you @cclauss for investing time in this one <3

@SaravgiYash
Copy link
Contributor Author

@mekarpeles Do I still need to break this PR into smaller PR or after #3909 this can be rebased as suggested by @cclauss .

@cclauss cclauss merged commit c9098a7 into internetarchive:master Oct 26, 2020
mekarpeles pushed a commit that referenced this pull request Oct 26, 2020
* removed unused imports 1

* batch2

* branch3

* batch4

* batch5

* batch6

* batch 7/8/9/10

* batch11

* batch12

* batch13

Co-authored-by: Christian Clauss <cclauss@me.com>
@@ -32,7 +32,6 @@
from infogami.utils.view import safeint

# TODO: i18n should be moved to core or infogami
from openlibrary.i18n import gettext as _
Copy link
Collaborator

Choose a reason for hiding this comment

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

@cclauss This looks like it is supposed to be where the i18n _() helper method that translates all the UI strings is imported. Has this been tested to ensure i18n doesn't break?

Even if this is non-breaking, the comment in line 34 relates to the deleted line and doesn't make any sense without it.

Copy link
Contributor

@cclauss cclauss Oct 28, 2020

Choose a reason for hiding this comment

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

Thanks. _() is not called in this file and a line like 69 (_, host, _, _, _ = urlsplit(href)) is going to shadow its value. I will create PR #3966 to remove the comment.

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.

4 participants