Input file:
import functools
from typing import Dict
print('Hello world!')
Now I run isort with --top argument:
isort --top typing test.py
Output:
~ $ cat test.py
import functools
from typing import Dict
print('Hello world!')
Not what I expected. BUT if I import this way:
import functools
import typing
print('Hello world!')
Now isort respects --top argument and places import typing first:
~ $ cat test.py
import typing
import functools
print('Hello world!')
I expected force_to_top option to work with from B import A imports.
I use isort v.4.3.16 with Python 3.7.
By default, isort sorts from B import A and import A statements separately, so the STDLIB section is split into two subsections, an imports section and a from section. You should find that typing is forced to the top of the from section:
from typing import Dict
import functools
from abc import ABCMeta
becomes
import functools
from typing import Dict
from abc import ABCMeta
Try the force_sort_within_sections option: https://github.com/timothycrosley/isort/wiki/isort-Settings
@PaperclipBadger's response is correct,
closing this issue as the functionality does work, though it could certainly use more complete documentation.
Thanks!
~Timothy