This repository was archived by the owner on Feb 19, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
pandas_dev_flaker/_plugins_tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 1
- [ ![ Build Status] ( https://github.com/pandas-dev/pandas-dev-flaker/workflows/tox/badge.svg )] ( https://github.com/pandas-dev/pandas-dev-flaker/actions?workflow=tox )
1
+ ![ Build Status] ( https://github.com/pandas-dev/pandas-dev-flaker/workflows/tox/badge.svg )] ( https://github.com/pandas-dev/pandas-dev-flaker/actions?workflow=tox )
2
2
[ ![ Coverage] ( https://codecov.io/gh/pandas-dev/pandas-dev-flaker/branch/main/graph/badge.svg )] ( https://codecov.io/gh/pandas-dev/pandas-dev-flaker )
3
3
4
4
pandas-dev-flaker
Original file line number Diff line number Diff line change
1
+ import ast
2
+ from typing import Iterator , Tuple
3
+
4
+ from pandas_dev_flaker ._data_tree import State , register
5
+
6
+ MSG = "PDF023 found assignment to single-letter variable"
7
+
8
+
9
+ @register (ast .Assign )
10
+ def visit_Assign (
11
+ state : State ,
12
+ node : ast .Assign ,
13
+ parent : ast .AST ,
14
+ ) -> Iterator [Tuple [int , int , str ]]:
15
+
16
+ # Unpacking is represented by putting a Tuple or List within targets
17
+ if isinstance (node .targets [0 ], (ast .Tuple , ast .List )):
18
+ assignment_names = node .targets [0 ].elts
19
+ else :
20
+ assignment_names = node .targets
21
+
22
+ for item in assignment_names :
23
+ if isinstance (item , ast .Name ) and item .id != "_" and len (item .id ) == 1 :
24
+ yield item .lineno , item .col_offset , MSG
You can’t perform that action at this time.
0 commit comments