-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Update isort script to match changes in the new release, isort v5.0.2 #1670
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1670 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 236 236
Lines 7150 7152 +2
=========================================
+ Hits 7150 7152 +2
Continue to review full report at Codecov.
|
I'm trying to get rid of this error on travis ci build but I can seem to figure out how to make the build pass. Any ideas? ERROR: /home/travis/build/tiangolo/fastapi/fastapi/utils.py Imports are incorrectly sorted and/or formatted.
ERROR: /home/travis/build/tiangolo/fastapi/fastapi/dependencies/utils.py Imports are incorrectly sorted and/or formatted.
ERROR: /home/travis/build/tiangolo/fastapi/fastapi/openapi/models.py Imports are incorrectly sorted and/or formatted.
ERROR: /home/travis/build/tiangolo/fastapi/tests/test_tutorial/test_additional_status_codes/test_tutorial001.py Imports are incorrectly sorted and/or formatted.
ERROR: /home/travis/build/tiangolo/fastapi/tests/test_tutorial/test_security/test_tutorial006.py Imports are incorrectly sorted and/or formatted.
ERROR: /home/travis/build/tiangolo/fastapi/tests/test_tutorial/test_security/test_tutorial001.py Imports are incorrectly sorted and/or formatted.
ERROR: /home/travis/build/tiangolo/fastapi/tests/test_tutorial/test_security/test_tutorial003.py Imports are incorrectly sorted and/or formatted.
ERROR: /home/travis/build/tiangolo/fastapi/tests/test_tutorial/test_security/test_tutorial005.py Imports are incorrectly sorted and/or formatted.
ERROR: /home/travis/build/tiangolo/fastapi/tests/test_tutorial/test_wsgi/test_tutorial001.py Imports are incorrectly sorted and/or formatted.
ERROR: /home/travis/build/tiangolo/fastapi/tests/test_tutorial/test_extra_models/test_tutorial003.py Imports are incorrectly sorted and/or formatted.
ERROR: /home/travis/build/tiangolo/fastapi/tests/test_tutorial/test_extra_models/test_tutorial004.py Imports are incorrectly sorted and/or formatted.
ERROR: /home/travis/build/tiangolo/fastapi/tests/test_tutorial/test_extra_models/test_tutorial005.py Imports are incorrectly sorted and/or formatted.
ERROR: /home/travis/build/tiangolo/fastapi/tests/test_tutorial/test_additional_responses/test_tutorial001.py Imports are incorrectly sorted and/or formatted.
ERROR: /home/travis/build/tiangolo/fastapi/tests/test_tutorial/test_additional_responses/test_tutorial003.py Imports are incorrectly sorted and/or formatted.
ERROR: /home/travis/build/tiangolo/fastapi/tests/test_tutorial/test_additional_responses/test_tutorial004.py Imports are incorrectly sorted and/or formatted. |
This was an easy fix. Apparently, with the new update in the command, the travis ci cache was updated so I had to run the formating script on my machine and push the changes to update travis cache. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tutorial files should consider fastapi
imports as third party.
fastapi/__init__.py
Outdated
@@ -1,7 +1,6 @@ | |||
"""FastAPI framework, high performance, easy to learn, fast to code, ready for production""" | |||
|
|||
__version__ = "0.58.1" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isort is removing this line? If yes, could you check why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure but looking into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is being fixed by isort team. see PyCQA/isort#1283
@@ -1,11 +1,10 @@ | |||
from typing import Optional | |||
|
|||
from fastapi import FastAPI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to use isort in this tutorial, because fastapi
and pydantic
are really third party imports here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fixed
@@ -1,6 +1,5 @@ | |||
from fastapi.testclient import TestClient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to use isort in this tutorial, because fastapi
are really third party here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to be in all the tutorials? If so, I can tell isort to ignore the files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all of them use fastapi as third party... If that's true, yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct. I've made adjustment in the new isort configuration file. This should be flexible.
otherwise it would try to format venv env directories, I have several with different Python versions
Thanks for your contribution @asheux ! 🍰 Thanks for the help here @Kludex ☕ I just updated it to use the Black profile and moved the config to I also updated the tests for the tutorial examples so that they can detect the sources as first party, without having to disable isort for big sections of code. Thanks for your contribution! 🚀 |
Apparently, isort latest release
isort v5.0.2
is missing the--recursive or -rc
flag and since the project uses the flag in it's script, it causes the tests to fail. An alternative to this is a dot, as inisort .
.Missing flags
Replacement
For more information on these changes see:
https://github.com/timothycrosley/isort/blob/develop/CHANGELOG.md#500-penny---july-4-2020
With this change, the build should be okay.