Closed sigmavirus24 closed 6 years ago
Thanks. I think this is the same as #123, which should be fixed in master if you could check? I'll release shortly if it does. Note that this is the commit that should fix this 87a611f0e24d2ccf0308944128ea47bd1eede2b8.
That fixes it if and only if I remove the new line after NullHandler
's docstring. If I keep the spacing as above, then it still reports I202.
I see, this makes sense in that the checker at the moment only knows that newlines exist and nothing about the surrounding context.
I think this is best to note in the limitations (imports within try-excepts are already ignored) as knowing about the context surrounding a newline seems to add too much complexity. Unless you disagree or this is not an isolated type of error...
diff --git a/README.rst b/README.rst
index b7ac22e..cca3e05 100644
--- a/README.rst
+++ b/README.rst
@@ -102,6 +102,26 @@ is also the same for all Python versions because otherwise it would
be impossible to write programs that work under both Python 2 and 3
*and* pass the import order check.
+The ``I202`` check will consider any blank line between imports to
+count, even if the line is not contextually related to the
+imports. For example,
+
+.. code-block:: python
+
+ import logging
+ try:
+ from logging import NullHandler
+ except ImportError:
+ class NullHandler(logging.Handler):
+ """Shim for version of Python < 2.7."""
+
+ def emit(self, record):
+ pass
+ import sys # I202 due to the blank line before the 'def emit'
+
+will trigger a ``I202`` error despite the blank line not being
+contextually related.
+
Extending styles
----------------
^ Proposed wording.
👍 And what's funnier, is that I just remembered that Flake8 3.0+ doesn't support Python 2.6 so in reality that should never be reached.
Thanks, it is in master, releasing now.
Hi there,
I upgraded
flake8-import-order
for flake8 and it started failing on L22 of oursrc/flake8/__init__.py
file. I couldn't figure out how to resolve it so I simply had to silence it. Below are the contents of the file:And this is the output of
flake8 --bug-report
in case that helps: