Skip to content
This repository was archived by the owner on Feb 19, 2023. It is now read-only.

Commit e6f4511

Browse files
committed
os remove
1 parent be66105 commit e6f4511

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

pandas_style_guide/__main__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from __future__ import annotations
2+
import tokenize
23

34

45
import ast
@@ -25,4 +26,4 @@ def run(self) -> Generator[tuple[int, int, str, type[Any]], None, None]:
2526
return
2627
for line, col, msg in callbacks:
2728
yield line, col, msg, type(self)
28-
29+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import ast
2+
from pandas_style_guide._data import register
3+
from pandas_style_guide._ast_helpers import is_name_attr
4+
5+
MSG = 'PSG010 os remove'
6+
@register(ast.Call)
7+
def check_contextless_pytest_raises(state, node, parent):
8+
if is_name_attr(node.func, state.from_imports, 'os', ('remove', )) and not isinstance(parent, ast.withitem):
9+
yield node.lineno, node.col_offset, MSG
10+
elif isinstance(node.func, ast.Attribute) and node.func.attr == 'remove' and isinstance(node.func.value, ast.Name) and node.func.value.id == 'os' and not isinstance(parent, ast.withitem):
11+
yield node.lineno, node.col_offset, MSG

t.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
from pandas.foo.bar.dude import _foo
44

55
_foo._foo('dod')
6+
os.remove('a')
7+
from os import remove
8+
remove('f')

0 commit comments

Comments
 (0)