mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Replace the project global linting rule excludes (as defined in .pep8) with fine-grained "# noqa" annotations. By using noqa annotation the excludes are made on a per line basis instead of globally. These annotations are used where we make deliberate deviations from the standard linting rules. To lint the Python code in the project: $ flake8 To install flake8: $ pip install flake8 See https://flake8.readthedocs.org/en/latest/ for details. To enable checking of the PEP-8 naming conventions, install the optional extension pep8-naming: $ pip install pep8-naming To enable checking of blind "except:" statements, install the optional extension flake8-blind-except: $ pip install flake8-blind-except To enable checking of import statement order, install the optional extension flake8-import-order: $ pip install flake8-import-order
48 lines
1.6 KiB
Python
Executable File
48 lines
1.6 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
import argparse
|
|
import json
|
|
import os
|
|
import sys
|
|
import textwrap
|
|
|
|
# Append the src dir
|
|
sys.path.append(os.path.join(os.path.dirname(
|
|
os.path.dirname(os.path.abspath(__file__))), 'src'))
|
|
|
|
import pass_pipeline_library # noqa (E402 module level import not at top of file)
|
|
|
|
import passes # noqa (E402)
|
|
|
|
normal_pipeline = list(pass_pipeline_library.normal_passpipelines())
|
|
pass_pipelines = [x.identifier for x in normal_pipeline]
|
|
|
|
parser = argparse.ArgumentParser(description=textwrap.dedent("""
|
|
Generate pass pipelines based off of the normal swift pipeline.
|
|
"""))
|
|
|
|
parser.add_argument('--disable-pass', nargs='*', help='Disable this pass',
|
|
choices=[x.name for x in passes.PASSES], action='append',
|
|
default=[])
|
|
parser.add_argument('--disable-passpipeline', nargs='*',
|
|
help='Disable this pass list', choices=pass_pipelines,
|
|
default=[], action='append')
|
|
|
|
args = parser.parse_args()
|
|
|
|
disabled_passes = sum(args.disable_pass, [])
|
|
disabled_passpipelines = sum(args.disable_passpipeline, [])
|
|
|
|
# First filter out pipelines.
|
|
normal_pipeline_generated = [x.generate()
|
|
for x in normal_pipeline
|
|
if x.identifier not in disabled_passpipelines]
|
|
|
|
# Then filter out specific passes.
|
|
for i in range(len(normal_pipeline_generated)):
|
|
normal_pipeline_generated[i] = [
|
|
x for x in normal_pipeline_generated[i] if x not in disabled_passes]
|
|
|
|
json.dump(normal_pipeline_generated, sys.stdout,
|
|
sort_keys=True, indent=4, separators=(',', ': '))
|