Update isort script to match changes in the new release, isort v5.0.2#1670
Conversation
|
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. |
Kludex
left a comment
There was a problem hiding this comment.
Tutorial files should consider fastapi imports as third party.
There was a problem hiding this comment.
isort is removing this line? If yes, could you check why?
There was a problem hiding this comment.
I'm not sure but looking into it.
There was a problem hiding this comment.
This is being fixed by isort team. see PyCQA/isort#1283
There was a problem hiding this comment.
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.
We don't want to use isort in this tutorial, because fastapi are really third party here.
There was a problem hiding this comment.
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.
I think all of them use fastapi as third party... If that's true, yes.
There was a problem hiding this comment.
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

Apparently, isort latest release
isort v5.0.2is missing the--recursive or -rcflag 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.