Skip to content

Commit 3a2ff9d

Browse files
modelmatcalcmogul
authored andcommitted
Use @staticmethod where methods are static
1 parent 79068b8 commit 3a2ff9d

15 files changed

+48
-24
lines changed

wpiformat/wpiformat/bracecomment.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
class BraceComment(Task):
1111

12-
def should_process_file(self, config_file, name):
12+
@staticmethod
13+
def should_process_file(config_file, name):
1314
return config_file.is_c_file(name) or config_file.is_cpp_file(name)
1415

1516
def run_pipeline(self, config_file, name, lines):

wpiformat/wpiformat/cidentlist.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77

88
class CIdentList(Task):
99

10-
def __print_failure(self, name):
10+
@staticmethod
11+
def __print_failure(name):
1112
print("Error: " + name + ": unmatched curly braces when scanning for "
1213
"C identifier lists. If the code compiles, this is a bug in "
1314
"wpiformat.")
1415

15-
def should_process_file(self, config_file, name):
16+
@staticmethod
17+
def should_process_file(config_file, name):
1618
return config_file.is_c_file(name) or config_file.is_cpp_file(name)
1719

1820
def run_pipeline(self, config_file, name, lines):

wpiformat/wpiformat/clangformat.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ def __init__(self, clang_version):
2222
else:
2323
self.exec_name = "clang-format-" + clang_version
2424

25-
def should_process_file(self, config_file, name):
25+
@staticmethod
26+
def should_process_file(config_file, name):
2627
return config_file.is_c_file(name) or config_file.is_cpp_file(name)
2728

2829
def run_pipeline(self, config_file, name, lines):

wpiformat/wpiformat/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ def is_c_header_file(self, name):
101101
"""
102102
return self.__c_header_include_regex.search(name) is not None
103103

104-
def is_c_src_file(self, name):
104+
@staticmethod
105+
def is_c_src_file(name):
105106
"""Returns True if file is C source file.
106107
107108
Keyword arguments:

wpiformat/wpiformat/includeguard.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ class State(Enum):
1717

1818
class IncludeGuard(Task):
1919

20-
def should_process_file(self, config_file, name):
20+
@staticmethod
21+
def should_process_file(config_file, name):
2122
return config_file.is_header_file(name)
2223

2324
def run_pipeline(self, config_file, name, lines):

wpiformat/wpiformat/includeorder.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ def __init__(self):
6969
r"(?P<close_bracket>>|\"))"
7070
r"(?P<postfix>.*)$")
7171

72-
def should_process_file(self, config_file, name):
72+
@staticmethod
73+
def should_process_file(config_file, name):
7374
return config_file.is_c_file(name) or config_file.is_cpp_file(name)
7475

7576
def classify_header(self, config_file, include_line, file_name):
@@ -112,7 +113,8 @@ def classify_header(self, config_file, include_line, file_name):
112113
else:
113114
return -1
114115

115-
def include_is_header(self, config_file, file_name, include_name):
116+
@staticmethod
117+
def include_is_header(config_file, file_name, include_name):
116118
"""Return True if include name has header extension.
117119
118120
Keyword arguments:
@@ -129,7 +131,8 @@ def include_is_header(self, config_file, file_name, include_name):
129131
else:
130132
return True
131133

132-
def rebuild_include(self, name_match, group_number):
134+
@staticmethod
135+
def rebuild_include(name_match, group_number):
133136
"""Adds appropriate brackets around include name and "#include" before
134137
that based on group number.
135138
@@ -151,7 +154,8 @@ def rebuild_include(self, name_match, group_number):
151154
else:
152155
return output
153156

154-
def dedup_list(self, seq):
157+
@staticmethod
158+
def dedup_list(seq):
155159
"""Remove duplicates from list while preserving order.
156160
157161
Keyword arguments:

wpiformat/wpiformat/javaclass.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
class JavaClass(Task):
99

10-
def should_process_file(self, config_file, name):
10+
@staticmethod
11+
def should_process_file(config_file, name):
1112
return name.endswith(".java")
1213

1314
def run_pipeline(self, config_file, name, lines):

wpiformat/wpiformat/jni.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@
2626

2727
class Jni(Task):
2828

29-
def should_process_file(self, config_file, name):
29+
@staticmethod
30+
def should_process_file(config_file, name):
3031
return config_file.is_cpp_src_file(name)
3132

32-
def map_jni_type(self, type_name):
33+
@staticmethod
34+
def map_jni_type(type_name):
3335
ret = ""
3436
if type_name.endswith("*") or type_name.endswith("Array"):
3537
ret += "["

wpiformat/wpiformat/licenseupdate.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212

1313
class LicenseUpdate(Task):
1414

15-
def should_process_file(self, config_file, name):
15+
@staticmethod
16+
def should_process_file(config_file, name):
1617
license_regex = config_file.regex("licenseUpdateExclude")
1718

1819
return (config_file.is_c_file(name) or config_file.is_cpp_file(name) or

wpiformat/wpiformat/lint.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717

1818
class Lint(Task):
1919

20-
def should_process_file(self, config_file, name):
20+
@staticmethod
21+
def should_process_file(config_file, name):
2122
return config_file.is_cpp_file(name)
2223

23-
def run_batch(self, config_file, names):
24+
@staticmethod
25+
def run_batch(config_file, names):
2426
# Handle running in either the root or styleguide directories
2527
cpplintPrefix = ""
2628
if os.getcwd().rpartition(os.sep)[2] != "styleguide":

0 commit comments

Comments
 (0)