35
35
import sys
36
36
from typing import Any , Dict , Generator , List , Tuple , Type , Union
37
37
38
+ __all__ = ["Visitor" , "Plugin" , "STRFTIME001" , "STRFTIME002" ]
39
+
38
40
__author__ = "Dominic Davis-Foster"
39
41
__copyright__ = "2020 Dominic Davis-Foster"
40
42
__license__ = "MIT"
@@ -55,6 +57,7 @@ def __init__(self) -> None:
55
57
56
58
def visit_Str (self , node : ast .Str ):
57
59
"""
60
+ Visit an AST Str node.
58
61
59
62
:param node: The node being visited
60
63
"""
@@ -66,6 +69,7 @@ def visit_Str(self, node: ast.Str):
66
69
67
70
def visit_Constant (self , node : ast .Constant ):
68
71
"""
72
+ Visit an AST Constant node.
69
73
70
74
:param node: The node being visited
71
75
"""
@@ -75,6 +79,7 @@ def visit_Constant(self, node: ast.Constant):
75
79
76
80
def _check_linux (self , node : Union [ast .Str , ast .Constant ]):
77
81
"""
82
+ Perform the check for Linux-specific codes.
78
83
79
84
:param node: The node being visited
80
85
"""
@@ -88,6 +93,7 @@ def _check_linux(self, node: Union[ast.Str, ast.Constant]):
88
93
89
94
def _check_windows (self , node : Union [ast .Str , ast .Constant ]):
90
95
"""
96
+ Perform the check for Windows-specific codes.
91
97
92
98
:param node: The node being visited
93
99
"""
@@ -101,13 +107,23 @@ def _check_windows(self, node: Union[ast.Str, ast.Constant]):
101
107
102
108
103
109
class Plugin :
110
+ """
111
+ The flake8 plugin.
112
+
113
+ :param tree:
114
+ """
115
+
104
116
name : str = __name__
105
117
version : str = __version__
106
118
107
119
def __init__ (self , tree : ast .AST ):
108
120
self ._tree = tree
109
121
110
122
def run (self ) -> Generator [Tuple [int , int , str , Type [Any ]], None , None ]:
123
+ """
124
+ Run the plugin.
125
+ """
126
+
111
127
visitor = Visitor ()
112
128
visitor .visit (self ._tree )
113
129
0 commit comments