diff --git a/pycodestyle.py b/pycodestyle.py index 868e79d5..2343f104 100755 --- a/pycodestyle.py +++ b/pycodestyle.py @@ -1195,7 +1195,10 @@ def module_imports_on_top_of_file( return if noqa: return - if logical_line.startswith(('import ', 'from ')): + if logical_line.startswith(( + 'import ', 'from ', + 'lazy import ', 'lazy from ', + )): if checker_state.get('seen_non_imports', False): yield 0, "E402 module level import not at top of file" elif not checker_state.get('seen_non_imports', False): diff --git a/testing/data/python315.py b/testing/data/python315.py new file mode 100644 index 00000000..e716b9a1 --- /dev/null +++ b/testing/data/python315.py @@ -0,0 +1,9 @@ +import os +lazy from typing import LiteralString +import sys +lazy import asyncio + +[*y for y in x] +{*y for y in x} +(*y for y in x) +{**y for y in x}