- I tried to use the add_import functionality like so:
add_imports = "from __future__ import annotations"
However, it kept destroying my module level docstrings by adding an import before the """ string.
In the project I was working on, we use raw multiline stringsr""" which may be messing with the heuristics to detect module level docstrings here:
|
and not lstripped_line.startswith('"""') |
As a temporary workaround, adding the append_only flag has seemed to fix it.
In short, isort will format my code like the following:
from __future__ import annotations
r"""module docstring
"""
from __future__ import annotations
Here is my isort config:
add_imports = "from __future__ import annotations"
# append_only = true # Enabling this is the workaround
profile = 'black'
treat_comments_as_code = "# %%"
add_imports = "from __future__ import annotations"However, it kept destroying my module level docstrings by adding an import before the """ string.
In the project I was working on, we use raw multiline strings
r"""which may be messing with the heuristics to detect module level docstrings here:isort/isort/parse.py
Line 218 in c6a4196
As a temporary workaround, adding the append_only flag has seemed to fix it.
In short, isort will format my code like the following:
Here is my isort config: