2017-06-05 16:43:16 +02:00
|
|
|
from __future__ import print_function
|
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2018-08-07 18:59:14 +02:00
|
|
|
import argparse
|
2017-07-06 06:52:03 +02:00
|
|
|
|
2019-02-02 23:53:29 +01:00
|
|
|
from typing import List
|
2017-06-05 16:43:16 +02:00
|
|
|
|
2019-05-28 18:29:36 +02:00
|
|
|
from zulint.linters import run_pyflakes
|
2018-01-23 22:53:45 +01:00
|
|
|
|
|
|
|
|
2019-05-28 18:29:36 +02:00
|
|
|
def check_pyflakes(files, options):
|
|
|
|
# type: (List[str], argparse.Namespace) -> bool
|
|
|
|
suppress_patterns = [
|
|
|
|
(b"scripts/lib/pythonrc.py", b"imported but unused"),
|
|
|
|
(b'', b"'scripts.lib.setup_path_on_import' imported but unused"),
|
2018-01-23 22:53:45 +01:00
|
|
|
|
2019-05-28 18:29:36 +02:00
|
|
|
# Our ipython startup pythonrc file intentionally imports *
|
|
|
|
(b"scripts/lib/pythonrc.py",
|
|
|
|
b" import *' used; unable to detect undefined names"),
|
2018-01-23 22:55:55 +01:00
|
|
|
|
2019-05-28 18:29:36 +02:00
|
|
|
# Special dev_settings.py import
|
|
|
|
(b'', b"from .prod_settings_template import *"),
|
2018-01-23 22:53:45 +01:00
|
|
|
|
2019-05-28 18:29:36 +02:00
|
|
|
(b"settings.py", b"settings import *' used; unable to detect undefined names"),
|
|
|
|
(b"settings.py", b"may be undefined, or defined from star imports"),
|
2018-01-23 22:53:45 +01:00
|
|
|
|
2019-05-28 18:29:36 +02:00
|
|
|
# Sphinx adds `tags` specially to the environment when running conf.py.
|
|
|
|
(b"docs/conf.py", b"undefined name 'tags'"),
|
|
|
|
]
|
2019-07-03 05:18:06 +02:00
|
|
|
if options.full:
|
|
|
|
suppress_patterns = []
|
2019-05-28 18:29:36 +02:00
|
|
|
return run_pyflakes(files, options, suppress_patterns)
|