The following file:
import sys
import _thread
import requests
gets sorted:
$ isort Test.py
Fixing Test.py
with the following results:
import sys
import requests
import _thread
It looks like built-in modules whose names start with _ (another example is _codecs) are not treated as STDLIB, but are treated like FIRSTPARTY instead, which seems wrong.
Discovered at https://github.com/PyCQA/pylint/issues/3304
I would suggest treating them like STDLIB where they belong, but then there's ambiguity. For now, when that is fixed, the sorting would put _thread in the beginning of the list, where it will be difficult to find. From my perspective, it would be appropriate to put it either to the end of the list, or before or after thread.
This should be fixed in develop and be pushed with the soon to be released 5.0.0 version.
Thanks!
~Timothy
@timothycrosley is this closed because it's been fixed, or will not be fixed?
Or by "should be fixed" did you mean "will be fixed", rather than "ought to be fixed"?
Strangely, I can work around this by using -b _thread with the CLI, but adding a builtin = ["_thread"] line in my pyproject.toml file doesn't work.
This is closed because it is fixed (albeit in develop branch):
In [1]: import isort
isor
In [2]: isort.place_module("_thread")
Out[2]: 'STDLIB'
The 5.0.0 release that includes this is slated to be released July 4th - you can find out more here: https://timothycrosley.github.io/isort/docs/major_releases/introducing_isort_5/
Thank you! isort is such a great tool. Appreciate the work.
That means a lot to me! Glad you find isort useful!