Skip to content

Commit 9fc3346

Browse files
committed
V0.3.5 & Support tuple all
1 parent 06df79a commit 9fc3346

File tree

6 files changed

+52
-24
lines changed

6 files changed

+52
-24
lines changed

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ inputs:
1212
runs:
1313
using: "composite"
1414
steps:
15-
- run: pip install --upgrade pip && python -m pip install pyall==0.3.4
15+
- run: pip install --upgrade pip && python -m pip install pyall==0.3.5
1616
shell: bash
1717
- run: pyall ${{ inputs.extra_args }}
1818
shell: bash

docs/changelog.md

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,20 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
77

88
## [Unreleased]
99

10-
## [0.3.4] - 2022-10-28
11-
12-
- Version fix
13-
14-
## [0.3.3] - 2022-10-28
15-
16-
### Added
17-
18-
- Python 3.11 support
19-
- Github Action
20-
21-
### Changed
22-
23-
- Single quotes to double quotes when refactoring
24-
25-
## [0.3.1] - 2022-07-17
10+
## [0.3.5] - 2022-10-28
2611

2712
### Added
2813

14+
- Support Python3.11
2915
- Support Python3.10
3016
- Add py.typed
17+
- Github Action
3118

3219
### Changed
3320

21+
- Single quotes to double quotes when refactoring
3422
- Apply src layout
23+
- Support tuple all
3524

3625
## [0.2.0] - 2021-04-11
3726

src/pyall/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
__all__ = ("__version__", "__description__")
22

3-
__version__ = "0.3.4"
4-
__description__ = (
3+
__version__ = "0.3.5" # pyall: public
4+
__description__ = ( # pyall: public
55
"Pyall is a linter that tries to keep the __all __ in your Python modules always up to date." # noqa: E501
66
)

src/pyall/analyzer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def visit_Name(self, node: ast.Name) -> None:
3737

3838
@Rule.apply
3939
def visit_Assign(self, node: ast.Assign) -> None:
40-
assert isinstance(node.value, ast.List)
40+
assert isinstance(node.value, (ast.List, ast.Tuple))
4141
for item in node.value.elts:
4242
if isinstance(item, ast.Constant):
4343
self.actual_all.add(str(item.value))
@@ -85,6 +85,7 @@ def set_extra_attr(self, tree: ast.AST) -> None:
8585
if re.search(C.ADD_COMMENTS_REGEX_PATTERN, line, re.IGNORECASE):
8686
lineno = start[0]
8787
add.add(lineno)
88+
8889
for node in ast.walk(tree):
8990
if isinstance(node, C.ALL_NODE) and node.lineno in skip:
9091
node.skip = True # type: ignore

src/pyall/rule.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ def _rule_def_name(node) -> bool:
106106

107107
@Rule.register((ast.Name,)) # type: ignore
108108
def _rule_name_name(node) -> bool:
109+
if hasattr(node, "add"):
110+
return node.add is True
109111
return (node.id.isupper() or node.id[0].isupper()) and not node.id.startswith("_")
110112

111113

tests/test_refactor.py

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,41 @@ def _is_equal_source_to_refactor(action: str, expected: str) -> bool:
4343
_key = "_value"
4444
Key = "Value"
4545
KEY = "VALUE"
46-
""",
46+
""",
4747
"""\
4848
__all__ = ["KEY", "Key"]
4949
5050
key = "value"
5151
_key = "_value"
5252
Key = "Value"
5353
KEY = "VALUE"
54-
""",
54+
""",
5555
),
5656
(
5757
"""\
5858
import x
5959
6060
def func():...
61-
""",
61+
""",
6262
"""\
6363
import x
6464
6565
__all__ = ["func"]
6666
6767
def func():...
68-
""",
68+
""",
69+
),
70+
(
71+
"""\
72+
__all__ = ("var",)
73+
74+
var = 1
75+
""",
76+
"""\
77+
__all__ = ("var",)
78+
79+
var = 1
80+
""",
6981
),
7082
(
7183
"""\
@@ -142,6 +154,30 @@ def x():...
142154
143155
""",
144156
),
157+
(
158+
"""\
159+
__all__ = ["x"]
160+
161+
x = 1 # pyall: public
162+
""",
163+
"""\
164+
__all__ = ["x"]
165+
166+
x = 1 # pyall: public
167+
""",
168+
),
169+
(
170+
"""\
171+
__all__ = []
172+
173+
XXX = 1 # pyall: not-public
174+
""",
175+
"""\
176+
__all__ = []
177+
178+
XXX = 1 # pyall: not-public
179+
""",
180+
),
145181
]
146182

147183

0 commit comments

Comments
 (0)