Skip to content

Commit

Permalink
test: Exclude asmap.py from Python linter checks
Browse files Browse the repository at this point in the history
asmap.py, a third-party dependency, is excluded from Python linter checks
because of `from __future__ import annotations` (PEP 563 postponed annotations)
this workaround can be removed when the Python version used is upgraded to 3.7+.
  • Loading branch information
laanwj committed May 31, 2022
1 parent c3e1b74 commit 1df513a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions test/lint/lint-python.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@

DEPS = ['flake8', 'mypy', 'pyzmq']
MYPY_CACHE_DIR = f"{os.getenv('BASE_ROOT_DIR', '')}/test/.mypy_cache"
FILES_ARGS = ['git', 'ls-files', 'test/functional/*.py', 'contrib/devtools/*.py']
# asmap.py, a third-party dependency, is excluded from Python linter checks
# because of `from __future__ import annotations` (PEP 563 postponed annotations)
# this workaround can be removed when the Python version used is upgraded to 3.7+.
EXCLUDED = ['contrib/seeds/asmap.py']

ENABLED = (
'E101,' # indentation contains mixed spaces and tabs
Expand Down Expand Up @@ -103,10 +106,11 @@ def check_dependencies():
def main():
check_dependencies()

exclude_args = [":(exclude)" + p for p in EXCLUDED]
if len(sys.argv) > 1:
flake8_files = sys.argv[1:]
else:
files_args = ['git', 'ls-files', '*.py']
files_args = ['git', 'ls-files', '*.py'] + exclude_args
flake8_files = subprocess.check_output(files_args).decode("utf-8").splitlines()

flake8_args = ['flake8', '--ignore=B,C,E,F,I,N,W', f'--select={ENABLED}'] + flake8_files
Expand All @@ -118,7 +122,8 @@ def main():
except subprocess.CalledProcessError:
exit(1)

mypy_files = subprocess.check_output(FILES_ARGS).decode("utf-8").splitlines()
files_args = ['git', 'ls-files', 'test/functional/*.py', 'contrib/devtools/*.py'] + exclude_args
mypy_files = subprocess.check_output(files_args).decode("utf-8").splitlines()
mypy_args = ['mypy', '--show-error-codes'] + mypy_files

try:
Expand Down

0 comments on commit 1df513a

Please sign in to comment.