40
40
# 3rd party
41
41
import flake8_helper
42
42
43
- __all__ = [ "Visitor" , "Plugin" , "STRFTIME001" , "STRFTIME002" ]
43
+ __all__ = ( "Visitor" , "Plugin" , "STRFTIME001" , "STRFTIME002" )
44
44
45
45
__author__ = "Dominic Davis-Foster"
46
46
__copyright__ = "2020-2021 Dominic Davis-Foster"
51
51
STRFTIME001 = "STRFTIME001 Linux-specific strftime code used."
52
52
STRFTIME002 = "STRFTIME002 Windows-specific strftime code used."
53
53
54
- _linux_re = re .compile (r"%-[dmHIMSj]" )
55
- _win_re = re .compile (r"%#[dmHIMSj]" )
56
-
57
54
58
55
class Visitor (flake8_helper .Visitor ):
59
56
"""
60
57
AST node visitor for identifying platform specific strftime codes.
61
58
""" # noqa: RST303
62
59
60
+ _linux_re = re .compile (r"%-[dmHIMSj]" )
61
+ _win_re = re .compile (r"%#[dmHIMSj]" )
62
+
63
63
def __init__ (self ) -> None :
64
64
super ().__init__ ()
65
65
self ._from_imports : Dict [str , str ] = {}
@@ -98,11 +98,11 @@ def _check_linux(self, node: Union[ast.Str, ast.Constant]) -> None:
98
98
:param node: The node being visited
99
99
"""
100
100
101
- for match in _linux_re .finditer (node .s ):
101
+ for match in self . _linux_re .finditer (node .s ): # pylint: disable=use-list-copy
102
102
self .errors .append ((
103
103
node .lineno ,
104
104
node .col_offset + match .span ()[0 ],
105
- STRFTIME001 ,
105
+ STRFTIME001 , # pylint: disable=loop-global-usage
106
106
))
107
107
108
108
def _check_windows (self , node : Union [ast .Str , ast .Constant ]) -> None :
@@ -112,11 +112,11 @@ def _check_windows(self, node: Union[ast.Str, ast.Constant]) -> None:
112
112
:param node: The node being visited
113
113
"""
114
114
115
- for match in _win_re .finditer (node .s ):
115
+ for match in self . _win_re .finditer (node .s ): # pylint: disable=use-list-copy
116
116
self .errors .append ((
117
117
node .lineno ,
118
118
node .col_offset + match .span ()[0 ],
119
- STRFTIME002 ,
119
+ STRFTIME002 , # pylint: disable=loop-global-usage
120
120
))
121
121
122
122
0 commit comments