Update isort script to match changes in the new release, isort v5.0.2 by asheux · Pull Request #1670 · fastapi/fastapi · GitHub
Skip to content

Update isort script to match changes in the new release, isort v5.0.2#1670

Merged
tiangolo merged 11 commits into
fastapi:masterfrom
asheux:update-isort-command
Jul 9, 2020
Merged

Update isort script to match changes in the new release, isort v5.0.2#1670
tiangolo merged 11 commits into
fastapi:masterfrom
asheux:update-isort-command

Conversation

@asheux

@asheux asheux commented Jul 5, 2020

Copy link
Copy Markdown
Contributor

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 in isort ..

Missing flags

--apply
--recursive

Replacement

isort .

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.

@codecov

codecov Bot commented Jul 5, 2020

Copy link
Copy Markdown

@asheux

asheux commented Jul 5, 2020

Copy link
Copy Markdown
Contributor Author

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.

@asheux

asheux commented Jul 6, 2020

Copy link
Copy Markdown
Contributor Author

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 Kludex left a comment

Copy link
Copy Markdown
Member

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.

Comment thread fastapi/__init__.py Outdated

Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor Author

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

Comment thread docs_src/nosql_databases/tutorial001.py Outdated

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is fixed

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Contributor Author

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.

@tiangolo tiangolo merged commit fe453f8 into fastapi:master Jul 9, 2020
@tiangolo

tiangolo commented Jul 9, 2020

Copy link
Copy Markdown
Member

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.

3 participants