Skip to content

Commit 182899d

Browse files
authored
Add Python flake8 linting for W291 trailing whitespace with Super-Linter (#4687)
* refactor: remove trailing whitespace from Python files * Add the GitHub Super-Linter Add Python flake8 linting for W291 trailing whitespace * Add licenses
1 parent add657a commit 182899d

File tree

168 files changed

+1942
-1894
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+1942
-1894
lines changed

.github/linters/.flake8

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
[flake8]
19+
select = W291

.github/workflows/linter.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
name: Lint Code Base
19+
20+
on: [pull_request]
21+
22+
jobs:
23+
build:
24+
name: GitHub Super Linter
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v2
28+
- uses: github/super-linter@v4
29+
env:
30+
VALIDATE_PYTHON_FLAKE8: true
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

cloud-cli/cloudapis/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
# to you under the Apache License, Version 2.0 (the
66
# "License"); you may not use this file except in compliance
77
# with the License. You may obtain a copy of the License at
8-
#
8+
#
99
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
10+
#
1111
# Unless required by applicable law or agreed to in writing,
1212
# software distributed under the License is distributed on an
1313
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
18+
1919

2020
'''
2121
Created on Aug 2, 2010

cloud-cli/cloudtool/__init__.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
# to you under the Apache License, Version 2.0 (the
66
# "License"); you may not use this file except in compliance
77
# with the License. You may obtain a copy of the License at
8-
#
8+
#
99
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
10+
#
1111
# Unless required by applicable law or agreed to in writing,
1212
# software distributed under the License is distributed on an
1313
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
18+
1919

2020
'''
2121
Created on Aug 2, 2010
@@ -26,16 +26,16 @@
2626
import cloudapis as apis
2727
import cloudtool.utils as utils
2828

29-
29+
3030
def main(argv=None):
31-
31+
3232
#import ipdb; ipdb.set_trace()
3333
if argv == None:
3434
argv = sys.argv
3535

3636
prelim_args = [ x for x in argv[0:] if not x.startswith('-') ]
3737
parser = utils.get_parser()
38-
38+
3939
api = __import__("cloudapis")
4040
apis = getattr(api, "implementor")
4141
if len(prelim_args) == 1:
@@ -44,20 +44,20 @@ def main(argv=None):
4444

4545
command = utils.lookup_command_in_api(apis,prelim_args[1])
4646
if not command: parser.error("command %r not supported by the %s API"%(prelim_args[1],prelim_args[0]))
47-
48-
argv = argv[1:]
47+
48+
argv = argv[1:]
4949
if len(argv) == 1:
5050
argv.append("--help")
5151

5252
parser = utils.get_parser(apis.__init__,command)
5353
opts,args,api_optionsdict,cmd_optionsdict = parser.parse_args(argv)
54-
55-
54+
55+
5656
try:
5757
api = apis(**api_optionsdict)
5858
except utils.OptParseError as e:
5959
parser.error(str(e))
60-
60+
6161
command = utils.lookup_command_in_api(api,args[0])
6262

6363
# we now discard the first two arguments as those necessarily are the api and command names

cloud-cli/cloudtool/utils.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
# to you under the Apache License, Version 2.0 (the
66
# "License"); you may not use this file except in compliance
77
# with the License. You may obtain a copy of the License at
8-
#
8+
#
99
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
10+
#
1111
# Unless required by applicable law or agreed to in writing,
1212
# software distributed under the License is distributed on an
1313
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
18+
1919

2020
'''
2121
Created on Aug 2, 2010
@@ -48,28 +48,28 @@ def error(self, msg):
4848
error("%s: %s\n" % (self.get_prog_name(),msg))
4949
self.print_usage(sys.stderr)
5050
self.exit(os.EX_USAGE)
51-
51+
5252
def parse_args(self,*args,**kwargs):
5353
options,arguments = OptionParser.parse_args(self,*args,**kwargs)
54-
54+
5555
def prune_options(options,alist):
5656
"""Given 'options' -- a list of arguments to OptionParser.add_option,
5757
and a set of optparse Values, return a dictionary of only those values
5858
that apply exclusively to 'options'"""
5959
return dict( [ (k,getattr(options,k)) for k in dir(options) if k in alist ] )
60-
60+
6161
api_options = prune_options(options,self.api_dests)
6262
cmd_options = prune_options(options,self.cmd_dests)
63-
63+
6464
return options,arguments,api_options,cmd_options
6565

6666

6767
def get_parser(api_callable=None,cmd_callable=None): # this should probably be the __init__ method of myoptionparser
68-
68+
6969
def getdefaulttag(default):
7070
if default is not None: return " [Default: %default]"
7171
return ''
72-
72+
7373
def get_arguments_and_options(callable):
7474
"""Infers and returns arguments and options based on a callable's signature.
7575
Cooperates with decorator @describe"""
@@ -96,37 +96,37 @@ def get_arguments_and_options(callable):
9696
return arguments,options
9797

9898
basic_usage = "usage: %prog [options...] "
99-
99+
100100
api_name = "<api>"
101101
cmd_name = "<command>"
102102
description = "%prog is a command-line tool to access several cloud APIs."
103103
arguments = ''
104104
argexp = ""
105-
105+
106106
if api_callable:
107107
api_name = api_callable.__module__.split(".")[-1].replace("_","-")
108108
api_arguments,api_options = get_arguments_and_options(api_callable)
109109
assert len(api_arguments) is 0 # no mandatory arguments for class initializers
110-
110+
111111
if cmd_callable:
112112
cmd_name = cmd_callable.__name__.replace("_","-")
113113
cmd_arguments,cmd_options = get_arguments_and_options(cmd_callable)
114114
if cmd_arguments:
115115
arguments = " " + " ".join( [ s[0].upper() for s in cmd_arguments ] )
116116
argexp = "\n\nArguments:\n" + "\n".join ( " %s\n %s"%(s.upper(),u) for s,u in cmd_arguments )
117117
description = cmd_callable.__doc__
118-
118+
119119
api_command = "%s %s"%(api_name,cmd_name)
120120

121121
if description: description = "\n\n" + description
122122
else: description = ''
123-
123+
124124
usage = basic_usage + api_command + arguments + description + argexp
125125

126126
parser = MyOptionParser(usage=usage, add_help_option=False)
127-
127+
128128
parser.add_option('--help', action="help")
129-
129+
130130
group = parser.add_option_group("General options")
131131
group.add_option('-v', '--verbose', dest="verbose", help="Print extra output")
132132

@@ -136,14 +136,14 @@ def get_arguments_and_options(callable):
136136
for a in api_options:
137137
group.add_option(a[0][0],**a[1])
138138
parser.api_dests.append(a[1]["dest"])
139-
139+
140140
parser.cmd_dests = []
141141
if cmd_callable and cmd_options:
142142
group = parser.add_option_group("Options for the %s command"%cmd_name)
143143
for a in cmd_options:
144144
group.add_option(a[0][0],**a[1])
145145
parser.cmd_dests.append(a[1]["dest"])
146-
146+
147147
return parser
148148

149149
def lookup_command_in_api(api,command_name):
@@ -155,7 +155,7 @@ def get_api_list(api):
155155
for cmd_name in dir(api):
156156
cmd = getattr(api,cmd_name)
157157
if callable(cmd) and not cmd_name.startswith("_"):
158-
apilist.append(cmd_name)
158+
apilist.append(cmd_name)
159159
return apilist
160160

161161
def get_command_list(api):

0 commit comments

Comments
 (0)