Skip to content

Commit 7046878

Browse files
authored
Merge pull request #1019 from PyCQA/issue/1018
Allow __all__ to be typed
2 parents bf0c5bc + d19b47a commit 7046878

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

pycodestyle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def lru_cache(maxsize=128): # noqa as it's a fake implementation.
169169
'while',
170170
)))
171171
)
172-
DUNDER_REGEX = re.compile(r'^__([^\s]+)__ = ')
172+
DUNDER_REGEX = re.compile(r"^__([^\s]+)__(?::\s*[a-zA-Z.0-9_\[\]\"]+)? = ")
173173
MATCH_CASE_REGEX = re.compile(r'^\s*\b(?:match|case)(\s*)(?=.*\:)')
174174
BLANK_EXCEPT_REGEX = re.compile(r"except\s*:")
175175

testsuite/python38.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,17 @@ def f3(
2828
#: E225:1:18
2929
if False or (x :=1):
3030
pass
31+
#: Okay
32+
import typing as t
33+
34+
__all__: t.List[str] = []
35+
36+
import logging
37+
38+
logging.getLogger(__name__)
39+
#: E402
40+
import typing as t
41+
42+
all_the_things: t.List[str] = []
43+
44+
import logging

0 commit comments

Comments
 (0)