Scrapy, a fast high-level web crawling & scraping framework for Python.
Use pylint
Adrián Chaves3b6f7ac9f2f5
diff --git a/.travis.yml b/.travis.ymlindex 0190a7f4d..28a19f4f0 100644--- a/.travis.yml+++ b/.travis.yml@@ -7,6 +7,8 @@ branches:- /^\d\.\d+\.\d+(rc\d+|\.dev\d+)?$/matrix:include:+ - env: TOXENV=pylint+ python: 3.7- env: TOXENV=py27python: 2.7- env: TOXENV=py27-pinneddiff --git a/docs/utils/linkfix.py b/docs/utils/linkfix.pyindex 6290adbe2..9acfc3b23 100755--- a/docs/utils/linkfix.py+++ b/docs/utils/linkfix.py@@ -14,50 +14,57 @@ Author: dufferzafarimport re-# Used for remembering the file (and its contents)-# so we don't have to open the same file again.-_filename = None-_contents = None--# A regex that matches standard linkcheck output lines-line_re = re.compile(u'(.*)\:\d+\:\s\[(.*)\]\s(?:(.*)\sto\s(.*)|(.*))')--# Read lines from the linkcheck output file-try:- with open("build/linkcheck/output.txt") as out:- output_lines = out.readlines()-except IOError:- print("linkcheck output not found; please run linkcheck first.")- exit(1)--# For every line, fix the respective file-for line in output_lines:- match = re.match(line_re, line)-- if match:- newfilename = match.group(1)- errortype = match.group(2)-- # Broken links can't be fixed and- # I am not sure what do with the local ones.- if errortype.lower() in ["broken", "local"]:- print("Not Fixed: " + line)- else:- # If this is a new file- if newfilename != _filename:- # Update the previous file- if _filename:- with open(_filename, "w") as _file:- _file.write(_contents)+def main():++ # Used for remembering the file (and its contents)+ # so we don't have to open the same file again.+ _filename = None+ _contents = None++ # A regex that matches standard linkcheck output lines+ line_re = re.compile(u'(.*)\:\d+\:\s\[(.*)\]\s(?:(.*)\sto\s(.*)|(.*))')++ # Read lines from the linkcheck output file+ try:+ with open("build/linkcheck/output.txt") as out:+ output_lines = out.readlines()+ except IOError:+ print("linkcheck output not found; please run linkcheck first.")+ exit(1)++ # For every line, fix the respective file+ for line in output_lines:+ match = re.match(line_re, line)++ if match:+ newfilename = match.group(1)+ errortype = match.group(2)- _filename = newfilename+ # Broken links can't be fixed and+ # I am not sure what do with the local ones.+ if errortype.lower() in ["broken", "local"]:+ print("Not Fixed: " + line)+ else:+ # If this is a new file+ if newfilename != _filename:++ # Update the previous file+ if _filename:+ with open(_filename, "w") as _file:+ _file.write(_contents)++ _filename = newfilename++ # Read the new file to memory+ with open(_filename) as _file:+ _contents = _file.read()++ _contents = _contents.replace(match.group(3), match.group(4))+ else:+ # We don't understand what the current line means!+ print("Not Understood: " + line)- # Read the new file to memory- with open(_filename) as _file:- _contents = _file.read()- _contents = _contents.replace(match.group(3), match.group(4))- else:- # We don't understand what the current line means!- print("Not Understood: " + line)+if __name__ == '__main__':+ main()diff --git a/pylintrc b/pylintrcnew file mode 100644index 000000000..b83bc9f82--- /dev/null+++ b/pylintrc@@ -0,0 +1,88 @@+[MASTER]+persistent=no+jobs=1 # >1 hides results++[MESSAGES CONTROL]+disable=abstract-method,+ anomalous-backslash-in-string,+ arguments-differ,+ attribute-defined-outside-init,+ bad-classmethod-argument,+ bad-continuation,+ bad-indentation,+ bad-mcs-classmethod-argument,+ bad-whitespace,+ broad-except,+ c-extension-no-member,+ catching-non-exception,+ cell-var-from-loop,+ comparison-with-callable,+ consider-using-in,+ cyclic-import,+ dangerous-default-value,+ deprecated-method,+ deprecated-module,+ duplicate-code, # https://github.com/PyCQA/pylint/issues/214+ eval-used,+ expression-not-assigned,+ fixme,+ function-redefined,+ global-statement,+ import-error,+ import-outside-toplevel,+ inconsistent-return-statements,+ inherit-non-class,+ invalid-name,+ keyword-arg-before-vararg,+ line-too-long,+ logging-format-interpolation,+ logging-not-lazy,+ lost-exception,+ method-hidden,+ missing-docstring,+ missing-final-newline,+ multiple-imports,+ multiple-statements,+ no-else-continue,+ no-else-raise,+ no-else-return,+ no-init,+ no-member,+ no-method-argument,+ no-name-in-module,+ no-self-argument,+ no-self-use,+ pointless-string-statement,+ protected-access,+ redefined-argument-from-local,+ redefined-builtin,+ redefined-outer-name,+ reimported,+ signature-differs,+ super-init-not-called,+ superfluous-parens,+ too-few-public-methods,+ too-many-ancestors,+ too-many-arguments,+ too-many-branches,+ too-many-function-args,+ too-many-instance-attributes,+ too-many-locals,+ too-many-return-statements,+ trailing-newlines,+ trailing-whitespace,+ unexpected-special-method-signature,+ ungrouped-imports,+ unidiomatic-typecheck,+ unnecessary-comprehension,+ unnecessary-pass,+ unsubscriptable-object,+ unused-argument,+ unused-import,+ unused-variable,+ unused-wildcard-import,+ used-before-assignment,+ useless-object-inheritance, # Required for Python 2 support+ wildcard-import,+ wrong-import-order,+ wrong-import-positiondiff --git a/tox.ini b/tox.iniindex ffe7360d3..e7d366fe9 100644--- a/tox.ini+++ b/tox.ini@@ -98,6 +98,20 @@ deps = {[testenv:py35]deps}commands =py.test {posargs:scrapy tests}+[testenv:pylint]+basepython = python3.7+deps =+ {[testenv:py35]deps}+ # Optional dependencies+ boto+ reppy+ robotexclusionrulesparser+ # Test dependencies+ pylint++commands =+ pylint scrapy+[docs]changedir = docsdeps =