github.com/munnerz/test-infra@v0.0.0-20190108210205-ce3d181dc989/hack/pylint_bin.py (about) 1 #!/usr/bin/env python2 2 3 # Copyright 2017 The Kubernetes Authors. 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # 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, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 import os 18 import sys 19 20 import pylint 21 22 if __name__ == '__main__': 23 # Otherwise bazel's symlinks confuse pylint/astroid 24 EXTRAS = set() 25 for path in sys.path: 26 if not os.path.isdir(path): 27 continue 28 for something in os.listdir(path): 29 full = os.path.join(path, something) 30 real = os.path.realpath(full) 31 if real != full: 32 EXTRAS.add(os.path.dirname(real)) 33 break 34 # also do one level up so foo.bar imports work :shrug: 35 EXTRAS = set(os.path.dirname(e) for e in EXTRAS).union(EXTRAS) 36 # append these to the path 37 sys.path.extend(EXTRAS) 38 39 # Otherwise this is the entirety of bin/pylint 40 pylint.run_pylint()