Skip to content

Commit 9258ef1

Browse files
tiangolomyint
authored andcommitted
Add note about # noqa comments to disable autoflake in specific lines (#43)
1 parent 83258a0 commit 9258ef1

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,32 @@ results change for the worse. (This is done in memory. The actual files are
139139
left untouched.)::
140140

141141
$ ./test_fuzz.py --verbose
142+
143+
144+
Excluding specific lines
145+
========================
146+
147+
It might be the case that you have some imports for their side effects, even
148+
if you are not using them directly in that file.
149+
150+
That is common, for example, in Flask based applications. In where you import
151+
Python modules (files) that imported a main ``app``, to have them included in
152+
the routes.
153+
154+
For example:
155+
156+
.. code-block:: python
157+
158+
from .endpoints import role, token, user, utils
159+
160+
As those imports are not being used directly, if you are using the option
161+
``--remove-all-unused-imports``, they would be removed.
162+
163+
To prevent that, without having to exclude the entire file, you can add a
164+
``# noqa`` comment at the end of the line, like:
165+
166+
.. code-block:: python
167+
168+
from .endpoints import role, token, user, utils # noqa
169+
170+
That line will instruct ``autoflake`` to let that specific line as is.

0 commit comments

Comments
 (0)