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

Use isort #5806

Merged
merged 8 commits into from
Jan 30, 2023
Merged

Use isort #5806

merged 8 commits into from
Jan 30, 2023

Conversation

jxlil
Copy link
Contributor

@jxlil jxlil commented Jan 25, 2023

Added isort to scrapy and sorted all imports.

Closes #5737, fixes #5810.

@codecov
Copy link

codecov bot commented Jan 26, 2023

Codecov Report

Merging #5806 (5dcf8b9) into master (e71eab6) will increase coverage by 0.02%.
The diff coverage is 99.24%.

❗ Current head 5dcf8b9 differs from pull request most recent head 17354a6. Consider uploading reports for the commit 17354a6 to get more accurate results

@@            Coverage Diff             @@
##           master    #5806      +/-   ##
==========================================
+ Coverage   88.91%   88.93%   +0.02%     
==========================================
  Files         162      162              
  Lines       10988    10992       +4     
  Branches     1797     1798       +1     
==========================================
+ Hits         9770     9776       +6     
+ Misses        938      937       -1     
+ Partials      280      279       -1     
Impacted Files Coverage Δ
scrapy/commands/view.py 92.30% <ø> (ø)
scrapy/core/downloader/contextfactory.py 87.50% <ø> (ø)
scrapy/core/downloader/handlers/__init__.py 92.72% <ø> (ø)
scrapy/core/downloader/handlers/http2.py 100.00% <ø> (ø)
scrapy/core/scheduler.py 93.75% <ø> (ø)
scrapy/core/spidermw.py 99.44% <ø> (ø)
scrapy/downloadermiddlewares/decompression.py 100.00% <ø> (ø)
scrapy/downloadermiddlewares/httpcache.py 93.97% <ø> (ø)
scrapy/extensions/statsmailer.py 0.00% <0.00%> (ø)
scrapy/http/headers.py 98.52% <ø> (ø)
... and 94 more

@Gallaecio
Copy link
Member

Gallaecio commented Jan 26, 2023

@jxlil What do you think about making #5734 (comment) part of this pull request? Instead of adding isort to tox.ini, we could actually remove from tox.ini and CI jobs anything that we handle with pre-commit now, and have a single pre-commit CI job.

@jxlil
Copy link
Contributor Author

jxlil commented Jan 26, 2023

@Gallaecio Sounds good. I will update this PR.

@jxlil jxlil marked this pull request as ready for review January 27, 2023 05:43
Copy link
Member

@Gallaecio Gallaecio left a comment

Choose a reason for hiding this comment

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

Sounds good. I will update this PR.

I was not just suggesting that you remove the tox entry for isort, but also add the pre-commit CI job, as described in #5734 (comment).

You don‘t have to do it, we can do it in a separate, later pull request, but then please add back the CI and tox configu you had. However we do it, after we merge this pull request we really want the CI to fail if any bad import sorting is introduced in the future.

.isort.cfg Outdated Show resolved Hide resolved
scrapy/__init__.py Outdated Show resolved Hide resolved
@@ -32,6 +32,7 @@ jobs:

steps:
- uses: actions/checkout@v3
- uses: pre-commit/action@v3.0.0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't have much experience adding CI jobs. However I believe that this action should cause CI to fail if pre-commit makes any changes.

Copy link
Member

Choose a reason for hiding this comment

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

Great finding!

@wRAR
Copy link
Member

wRAR commented Jan 28, 2023

     RuntimeError: The Poetry configuration is invalid:
       - [extras.pipfile_deprecated_finder.2] 'pip-shims<=0.3.4' does not match '^[a-zA-Z-_.0-9]+$'

Uhh. Is this some problem with the pre-commit action itself?

@jxlil
Copy link
Contributor Author

jxlil commented Jan 29, 2023

This problem is related to isort, updating to version 5.12.0 fixes the bug (PyCQA/isort#2077). However, this version supports only Python 3.8+, should I update the action to something like this?

- name: pre-commit
  uses: pre-commit/action@v3.0.0
  with:
    python-version: "3.11"

In the logs I see that pre-commit uses Python 3.10 by default.

@Gallaecio
Copy link
Member

The problem I see with the current CI approach is that it will run pre-commit for every check job. And also, we should remove the CI jobs that are not needed once we have a pre-commit CI job.

Let me make some changes to the CI file myself…

Comment on lines -11 to -15
- repo: https://github.com/PyCQA/pylint
rev: v2.15.6
hooks:
- id: pylint
args: [conftest.py, docs, extras, scrapy, setup.py, tests]
Copy link
Member

Choose a reason for hiding this comment

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

Done to address #5810, since otherwise we would be removing pylint from checks.yml in this pull request to re-add it when we remove pylint from pre-commit.

Copy link
Member

@Gallaecio Gallaecio left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks!

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.

Remove pylint from pre-commit Use isort
3 participants