diff options
author | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2019-03-09 11:23:15 +0100 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2019-03-20 09:07:35 +0100 |
commit | 2d525d68249cf00c4dbb521e331e99b481a113c3 (patch) | |
tree | 29ab4faad229c838ab74b97349fd9922cd14613e | |
parent | 5ab140ac3b3dda6f32e0f73aeec09abf015ea30f (diff) | |
download | pylint-git-2d525d68249cf00c4dbb521e331e99b481a113c3.tar.gz |
Style - Re-Apply black following the isort cleanup
Change with isort triggered change with black.
-rw-r--r-- | doc/conf.py | 127 | ||||
-rwxr-xr-x | doc/exts/pylint_extensions.py | 75 | ||||
-rwxr-xr-x | doc/exts/pylint_features.py | 12 | ||||
-rw-r--r-- | examples/custom.py | 32 | ||||
-rw-r--r-- | examples/custom_raw.py | 22 | ||||
-rw-r--r-- | pylint/__main__.py | 1 | ||||
-rw-r--r-- | pylint/checkers/similar.py | 4 | ||||
-rw-r--r-- | pylint/checkers/spelling.py | 1 | ||||
-rw-r--r-- | pylint/config.py | 3 | ||||
-rw-r--r-- | pylint/extensions/mccabe.py | 1 | ||||
-rw-r--r-- | pylint/lint.py | 1 | ||||
-rw-r--r-- | pylint/pyreverse/__init__.py | 1 | ||||
-rw-r--r-- | pylint/test/extensions/test_check_docs.py | 6 | ||||
-rw-r--r-- | pylint/test/test_functional.py | 4 | ||||
-rw-r--r-- | pylint/test/unittest_checker_typecheck.py | 2 | ||||
-rw-r--r-- | pylint/test/unittest_pyreverse_inspector.py | 2 | ||||
-rw-r--r-- | setup.py | 123 |
17 files changed, 216 insertions, 201 deletions
diff --git a/doc/conf.py b/doc/conf.py index 16bfb7eb9..f71c4d341 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -25,204 +25,204 @@ from pylint.__pkginfo__ import version # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.append(os.path.abspath('exts')) +sys.path.append(os.path.abspath("exts")) # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +# needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = [ - 'pylint_features', - 'pylint_extensions', - 'sphinx.ext.autosectionlabel', - 'sphinx.ext.intersphinx', + "pylint_features", + "pylint_extensions", + "sphinx.ext.autosectionlabel", + "sphinx.ext.intersphinx", ] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix of source filenames. -source_suffix = '.rst' +source_suffix = ".rst" # The encoding of source files. -#source_encoding = 'utf-8-sig' +# source_encoding = 'utf-8-sig' # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = 'Pylint' +project = "Pylint" current_year = datetime.utcnow().year -copyright = '2003-{year}, Logilab, PyCQA and contributors'.format(year=current_year) +copyright = "2003-{year}, Logilab, PyCQA and contributors".format(year=current_year) # The full version, including alpha/beta/rc tags. release = version # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -#language = None +# language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = ['_build'] +exclude_patterns = ["_build"] # The reST default role (used for this markup: `text`) to use for all documents. -#default_role = None +# default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True +# add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -#add_module_names = True +# add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -#show_authors = False +# show_authors = False # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] +# modindex_common_prefix = [] # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'python_docs_theme' +html_theme = "python_docs_theme" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. html_theme_options = { - 'collapsiblesidebar': True, - 'issues_url': 'https://github.com/pycqa/pylint/issues/new', - 'root_name': 'PyCQA', - 'root_url': 'http://meta.pycqa.org/en/latest/', + "collapsiblesidebar": True, + "issues_url": "https://github.com/pycqa/pylint/issues/new", + "root_name": "PyCQA", + "root_url": "http://meta.pycqa.org/en/latest/", } # Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] +# html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # "<project> v<release> documentation". -#html_title = None +# html_title = None # A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None +# html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. -#html_logo = None +# html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -#html_favicon = None +# html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -#html_static_path = ['_static'] +# html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = '%b %d, %Y' smartquotes = False # Custom sidebar templates, maps document names to template names. html_sidebars = { - '**': [ - 'localtoc.html', - 'globaltoc.html', - 'relations.html', - 'sourcelink.html' - ] + "**": ["localtoc.html", "globaltoc.html", "relations.html", "sourcelink.html"] } # Additional templates that should be rendered to pages, maps page names to # template names. -#html_additional_pages = {} +# html_additional_pages = {} # If false, no module index is generated. -#html_domain_indices = True +# html_domain_indices = True # If false, no index is generated. -#html_use_index = True +# html_use_index = True # If true, the index is split into individual pages for each letter. -#html_split_index = False +# html_split_index = False # If true, links to the reST sources are added to the pages. html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True +# html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True +# html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a <link> tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -#html_use_opensearch = '' +# html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None +# html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = 'Pylintdoc' +htmlhelp_basename = "Pylintdoc" # -- Options for LaTeX output -------------------------------------------------- # The paper size ('letter' or 'a4'). -#latex_paper_size = 'letter' +# latex_paper_size = 'letter' # The font size ('10pt', '11pt' or '12pt'). -#latex_font_size = '10pt' +# latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('index', 'Pylint.tex', 'Pylint Documentation', - 'Logilab, PyCQA and contributors', 'manual'), + ( + "index", + "Pylint.tex", + "Pylint Documentation", + "Logilab, PyCQA and contributors", + "manual", + ) ] # The name of an image file (relative to this directory) to place at the top of # the title page. -#latex_logo = None +# latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. -#latex_use_parts = False +# latex_use_parts = False # If true, show page references after internal links. -#latex_show_pagerefs = False +# latex_show_pagerefs = False # If true, show URL addresses after external links. -#latex_show_urls = False +# latex_show_urls = False # Additional stuff for the LaTeX preamble. -#latex_preamble = '' +# latex_preamble = '' # Documents to append as an appendix to all manuals. -#latex_appendices = [] +# latex_appendices = [] # If false, no module index is generated. -#latex_domain_indices = True +# latex_domain_indices = True # -- Options for manual page output -------------------------------------------- @@ -230,13 +230,12 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'pylint', 'Pylint Documentation', - ['Logilab, PyCQA and contributors'], 1) + ("index", "pylint", "Pylint Documentation", ["Logilab, PyCQA and contributors"], 1) ] intersphinx_mapping = { - 'astroid': ('http://astroid.readthedocs.io/en/latest/', None), - 'python': ('https://docs.python.org/3', None), + "astroid": ("http://astroid.readthedocs.io/en/latest/", None), + "python": ("https://docs.python.org/3", None), } # Prevent label issues due to colliding section names diff --git a/doc/exts/pylint_extensions.py b/doc/exts/pylint_extensions.py index 2e1d82163..dd660767c 100755 --- a/doc/exts/pylint_extensions.py +++ b/doc/exts/pylint_extensions.py @@ -18,28 +18,27 @@ from pylint.lint import PyLinter # 1) They are deprecated, why document them moving forward? # 2) We can't load the deprecated module and the newly renamed module at the # same time without getting naming conflicts -DEPRECATED_MODULES = [ - 'check_docs', # ==> docparams -] +DEPRECATED_MODULES = ["check_docs"] # ==> docparams + def builder_inited(app): """Output full documentation in ReST format for all extension modules""" # PACKAGE/docs/exts/pylint_extensions.py --> PACKAGE/ base_path = os.path.dirname( - os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + ) # PACKAGE/ --> PACKAGE/pylint/extensions - ext_path = os.path.join(base_path, 'pylint', 'extensions') + ext_path = os.path.join(base_path, "pylint", "extensions") modules = [] doc_files = {} for filename in os.listdir(ext_path): name, ext = os.path.splitext(filename) - if name[0] == '_' or name in DEPRECATED_MODULES: + if name[0] == "_" or name in DEPRECATED_MODULES: continue - if ext == '.py': - modules.append('pylint.extensions.%s' % name) - elif ext == '.rst': - doc_files['pylint.extensions.' + name] = os.path.join(ext_path, - filename) + if ext == ".py": + modules.append("pylint.extensions.%s" % name) + elif ext == ".rst": + doc_files["pylint.extensions." + name] = os.path.join(ext_path, filename) modules.sort() if not modules: sys.exit("No Pylint extensions found?") @@ -47,29 +46,35 @@ def builder_inited(app): linter = PyLinter() linter.load_plugin_modules(modules) - extensions_doc = os.path.join(base_path, 'doc', 'technical_reference', 'extensions.rst') - with open(extensions_doc, 'w') as stream: + extensions_doc = os.path.join( + base_path, "doc", "technical_reference", "extensions.rst" + ) + with open(extensions_doc, "w") as stream: stream.write("Optional Pylint checkers in the extensions module\n") stream.write("=================================================\n\n") stream.write("Pylint provides the following optional plugins:\n\n") for module in modules: stream.write("- :ref:`{}`\n".format(module)) stream.write("\n") - stream.write("You can activate any or all of these extensions " - "by adding a ``load-plugins`` line to the ``MASTER`` " - "section of your ``.pylintrc``, for example::\n") - stream.write("\n load-plugins=pylint.extensions.docparams," - "pylint.extensions.docstyle\n\n") + stream.write( + "You can activate any or all of these extensions " + "by adding a ``load-plugins`` line to the ``MASTER`` " + "section of your ``.pylintrc``, for example::\n" + ) + stream.write( + "\n load-plugins=pylint.extensions.docparams," + "pylint.extensions.docstyle\n\n" + ) by_module = get_plugins_info(linter, doc_files) for module, info in sorted(by_module.items()): - linter._print_checker_doc(info['name'], info, stream=stream) + linter._print_checker_doc(info["name"], info, stream=stream) def get_plugins_info(linter, doc_files): by_module = {} for checker in linter.get_checkers(): - if checker.name == 'master': + if checker.name == "master": continue module = checker.__module__ # Plugins only - skip over core checkers @@ -80,32 +85,32 @@ def get_plugins_info(linter, doc_files): doc = "" doc_file = doc_files.get(module) if doc_file: - with open(doc_file, 'r') as f: + with open(doc_file, "r") as f: doc = f.read() try: - by_module[module]['options'] += checker.options_and_values() - by_module[module]['msgs'].update(checker.msgs) - by_module[module]['reports'] += checker.reports - by_module[module]['doc'] += doc - by_module[module]['name'] += checker.name - by_module[module]['module'] += module + by_module[module]["options"] += checker.options_and_values() + by_module[module]["msgs"].update(checker.msgs) + by_module[module]["reports"] += checker.reports + by_module[module]["doc"] += doc + by_module[module]["name"] += checker.name + by_module[module]["module"] += module except KeyError: by_module[module] = { - 'options': list(checker.options_and_values()), - 'msgs': dict(checker.msgs), - 'reports': list(checker.reports), - 'doc': doc, - 'name': checker.name, - 'module': module, + "options": list(checker.options_and_values()), + "msgs": dict(checker.msgs), + "reports": list(checker.reports), + "doc": doc, + "name": checker.name, + "module": module, } return by_module def setup(app): - app.connect('builder-inited', builder_inited) - return {'version': sphinx.__display_version__} + app.connect("builder-inited", builder_inited) + return {"version": sphinx.__display_version__} if __name__ == "__main__": diff --git a/doc/exts/pylint_features.py b/doc/exts/pylint_features.py index 2ff0e52a7..4803efc9a 100755 --- a/doc/exts/pylint_features.py +++ b/doc/exts/pylint_features.py @@ -15,12 +15,13 @@ from pylint.lint import PyLinter def builder_inited(app): # PACKAGE/docs/exts/pylint_extensions.py --> PACKAGE/ base_path = os.path.dirname( - os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + ) linter = PyLinter() linter.load_default_plugins() - features = os.path.join(base_path, 'doc', 'technical_reference', 'features.rst') - with open(features, 'w') as stream: + features = os.path.join(base_path, "doc", "technical_reference", "features.rst") + with open(features, "w") as stream: stream.write("Pylint features\n") stream.write("===============\n\n") stream.write(".. generated by pylint --full-documentation\n\n") @@ -28,8 +29,9 @@ def builder_inited(app): def setup(app): - app.connect('builder-inited', builder_inited) - return {'version': sphinx.__display_version__} + app.connect("builder-inited", builder_inited) + return {"version": sphinx.__display_version__} + if __name__ == "__main__": builder_inited(None) diff --git a/examples/custom.py b/examples/custom.py index 039b018b8..7ee97bb5f 100644 --- a/examples/custom.py +++ b/examples/custom.py @@ -14,7 +14,7 @@ class MyAstroidChecker(BaseChecker): __implements__ = IAstroidChecker # The name defines a custom section of the config for this checker. - name = 'custom' + name = "custom" # The priority indicates the order that pylint will run the checkers. priority = -1 # This class variable declares the messages (ie the warnings and errors) @@ -24,9 +24,7 @@ class MyAstroidChecker(BaseChecker): # a unique symbol that identifies the message, # and a detailed help message # that will be included in the documentation. - 'W0001': ('Message that will be emitted', - 'message-symbol', - 'Message help') + "W0001": ("Message that will be emitted", "message-symbol", "Message help") } # This class variable declares the options # that are configurable by the user. @@ -35,12 +33,16 @@ class MyAstroidChecker(BaseChecker): # and in config files, and a dictionary of arguments # (similar to those to those to # argparse.ArgumentParser.add_argument). - ('store-locals-indicator', - {'default': 'properties', - 'help': ('The expression name that indicates that the locals should ' - 'be stored'), - }, - ), + ( + "store-locals-indicator", + { + "default": "properties", + "help": ( + "The expression name that indicates that the locals should " + "be stored" + ), + }, + ), ) def visit_call(self, node): @@ -51,10 +53,12 @@ class MyAstroidChecker(BaseChecker): :param node: The node to check. :type node: astroid.node_classes.Call """ - if not (isinstance(node.func, astroid.Attribute) - and isinstance(node.func.expr, astroid.Name) - and node.func.expr.name == self.config.store_locals_indicator - and node.func.attrname == 'create'): + if not ( + isinstance(node.func, astroid.Attribute) + and isinstance(node.func.expr, astroid.Name) + and node.func.expr.name == self.config.store_locals_indicator + and node.func.attrname == "create" + ): return in_class = node.frame() for param in node.args: diff --git a/examples/custom_raw.py b/examples/custom_raw.py index fb28d4931..63e4aeb8e 100644 --- a/examples/custom_raw.py +++ b/examples/custom_raw.py @@ -9,12 +9,17 @@ class MyRawChecker(BaseChecker): __implements__ = IRawChecker - name = 'custom_raw' - msgs = {'W9901': ('use \\ for line continuation', - 'backslash-line-continuation', - ('Used when a \\ is used for a line continuation instead' - ' of using triple quoted string or parenthesis.')), - } + name = "custom_raw" + msgs = { + "W9901": ( + "use \\ for line continuation", + "backslash-line-continuation", + ( + "Used when a \\ is used for a line continuation instead" + " of using triple quoted string or parenthesis." + ), + ) + } options = () def process_module(self, node): @@ -24,9 +29,8 @@ class MyRawChecker(BaseChecker): """ with node.stream() as stream: for (lineno, line) in enumerate(stream): - if line.rstrip().endswith('\\'): - self.add_message('backslash-line-continuation', - line=lineno) + if line.rstrip().endswith("\\"): + self.add_message("backslash-line-continuation", line=lineno) def register(linter): diff --git a/pylint/__main__.py b/pylint/__main__.py index 7eca11929..e12309b4d 100644 --- a/pylint/__main__.py +++ b/pylint/__main__.py @@ -1,4 +1,3 @@ - # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html # For details: https://github.com/PyCQA/pylint/blob/master/COPYING diff --git a/pylint/checkers/similar.py b/pylint/checkers/similar.py index d79785d66..f65f533cd 100644 --- a/pylint/checkers/similar.py +++ b/pylint/checkers/similar.py @@ -109,7 +109,7 @@ class Similar: % ( nb_total_lignes, nb_lignes_dupliquees, - nb_lignes_dupliquees * 100. / nb_total_lignes, + nb_lignes_dupliquees * 100.0 / nb_total_lignes, ) ) @@ -387,7 +387,7 @@ class SimilarChecker(BaseChecker, Similar): self.add_message("R0801", args=(len(couples), "\n".join(msg))) duplicated += num * (len(couples) - 1) stats["nb_duplicated_lines"] = duplicated - stats["percent_duplicated_lines"] = total and duplicated * 100. / total + stats["percent_duplicated_lines"] = total and duplicated * 100.0 / total def register(linter): diff --git a/pylint/checkers/spelling.py b/pylint/checkers/spelling.py index f1952e89f..c1a0eb2de 100644 --- a/pylint/checkers/spelling.py +++ b/pylint/checkers/spelling.py @@ -47,7 +47,6 @@ except ImportError: pass - if enchant is not None: br = enchant.Broker() dicts = br.list_dicts() diff --git a/pylint/config.py b/pylint/config.py index a913f8619..8b0373f61 100644 --- a/pylint/config.py +++ b/pylint/config.py @@ -57,9 +57,6 @@ from pylint import utils # need a cleanup. It could be completely reengineered as well. - - - USER_HOME = os.path.expanduser("~") if "PYLINTHOME" in os.environ: PYLINT_HOME = os.environ["PYLINTHOME"] diff --git a/pylint/extensions/mccabe.py b/pylint/extensions/mccabe.py index 69bc1775b..18baa2601 100644 --- a/pylint/extensions/mccabe.py +++ b/pylint/extensions/mccabe.py @@ -11,7 +11,6 @@ from __future__ import absolute_import from mccabe import PathGraph as Mccabe_PathGraph from mccabe import PathGraphingAstVisitor as Mccabe_PathGraphingAstVisitor - from pylint import checkers from pylint.checkers.utils import check_messages from pylint.interfaces import HIGH, IAstroidChecker diff --git a/pylint/lint.py b/pylint/lint.py index d02410fa0..25129ecb1 100644 --- a/pylint/lint.py +++ b/pylint/lint.py @@ -86,7 +86,6 @@ except ImportError: multiprocessing = None # type: ignore - MANAGER = astroid.MANAGER diff --git a/pylint/pyreverse/__init__.py b/pylint/pyreverse/__init__.py index 8a12c4fec..9ca1da5c6 100644 --- a/pylint/pyreverse/__init__.py +++ b/pylint/pyreverse/__init__.py @@ -1,4 +1,3 @@ - # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html # For details: https://github.com/PyCQA/pylint/blob/master/COPYING diff --git a/pylint/test/extensions/test_check_docs.py b/pylint/test/extensions/test_check_docs.py index 63825c415..1eacc9387 100644 --- a/pylint/test/extensions/test_check_docs.py +++ b/pylint/test/extensions/test_check_docs.py @@ -762,7 +762,7 @@ class TestParamDocChecker(CheckerTestCase): '''docstring foo :param y: bla - + missing constructor parameter documentation ''' @@ -794,7 +794,7 @@ class TestParamDocChecker(CheckerTestCase): Args: y: bla - + missing constructor parameter documentation ''' @@ -828,7 +828,7 @@ class TestParamDocChecker(CheckerTestCase): ---------- y: bla - + missing constructor parameter documentation ''' diff --git a/pylint/test/test_functional.py b/pylint/test/test_functional.py index ae673bd13..128063165 100644 --- a/pylint/test/test_functional.py +++ b/pylint/test/test_functional.py @@ -22,10 +22,10 @@ import re import sys import pytest -import six -from six.moves import configparser +import six from pylint import checkers, interfaces, lint, reporters +from six.moves import configparser class test_dialect(csv.excel): diff --git a/pylint/test/unittest_checker_typecheck.py b/pylint/test/unittest_checker_typecheck.py index a418087c2..7bce396c5 100644 --- a/pylint/test/unittest_checker_typecheck.py +++ b/pylint/test/unittest_checker_typecheck.py @@ -50,7 +50,7 @@ class TestTypeChecker(CheckerTestCase): node = astroid.extract_node( """ import optparse - optparse.THIS_does_not_EXIST + optparse.THIS_does_not_EXIST """ ) with self.assertAddsMessages( diff --git a/pylint/test/unittest_pyreverse_inspector.py b/pylint/test/unittest_pyreverse_inspector.py index c4433ba51..fe5df9b98 100644 --- a/pylint/test/unittest_pyreverse_inspector.py +++ b/pylint/test/unittest_pyreverse_inspector.py @@ -94,7 +94,7 @@ def test_interfaces(): class AnotherIFace(Interface): pass class Concrete0(object): __implements__ = MyIFace - class Concrete1: + class Concrete1: __implements__ = (MyIFace, AnotherIFace) class Concrete2: __implements__ = (MyIFace, AnotherIFace) @@ -35,36 +35,37 @@ try: from setuptools import setup from setuptools.command import easy_install as easy_install_lib from setuptools.command import install_lib + USE_SETUPTOOLS = 1 except ImportError: from distutils.core import setup from distutils.command import install_lib + USE_SETUPTOOLS = 0 easy_install_lib = None - base_dir = os.path.dirname(__file__) __pkginfo__ = {} with open(os.path.join(base_dir, "pylint", "__pkginfo__.py")) as f: exec(f.read(), __pkginfo__) -modname = __pkginfo__['modname'] -distname = __pkginfo__.get('distname', modname) -scripts = __pkginfo__.get('scripts', []) -data_files = __pkginfo__.get('data_files', None) -include_dirs = __pkginfo__.get('include_dirs', []) -ext_modules = __pkginfo__.get('ext_modules', None) -install_requires = __pkginfo__.get('install_requires', None) -dependency_links = __pkginfo__.get('dependency_links', []) -extras_require = __pkginfo__.get('extras_require', {}) - -readme_path = join(base_dir, 'README.rst') +modname = __pkginfo__["modname"] +distname = __pkginfo__.get("distname", modname) +scripts = __pkginfo__.get("scripts", []) +data_files = __pkginfo__.get("data_files", None) +include_dirs = __pkginfo__.get("include_dirs", []) +ext_modules = __pkginfo__.get("ext_modules", None) +install_requires = __pkginfo__.get("install_requires", None) +dependency_links = __pkginfo__.get("dependency_links", []) +extras_require = __pkginfo__.get("extras_require", {}) + +readme_path = join(base_dir, "README.rst") if exists(readme_path): with open(readme_path) as stream: long_description = stream.read() else: - long_description = '' + long_description = "" def ensure_scripts(linux_scripts): @@ -72,8 +73,9 @@ def ensure_scripts(linux_scripts): (taken from 4Suite) """ from distutils import util - if util.get_platform()[:3] == 'win': - return linux_scripts + [script + '.bat' for script in linux_scripts] + + if util.get_platform()[:3] == "win": + return linux_scripts + [script + ".bat" for script in linux_scripts] return linux_scripts @@ -83,9 +85,9 @@ def get_packages(directory, prefix): for package in os.listdir(directory): absfile = join(directory, package) if isdir(absfile): - if exists(join(absfile, '__init__.py')): + if exists(join(absfile, "__init__.py")): if prefix: - result.append('%s.%s' % (prefix, package)) + result.append("%s.%s" % (prefix, package)) else: result.append(package) result += get_packages(absfile, result[-1]) @@ -93,7 +95,7 @@ def get_packages(directory, prefix): def _filter_tests(files): - testdir = join('pylint', 'test') + testdir = join("pylint", "test") return [f for f in files if testdir not in f] @@ -101,6 +103,7 @@ class MyInstallLib(install_lib.install_lib): """extend install_lib command to handle package __init__.py and include_dirs variable if necessary """ + def run(self): """overridden from install_lib class""" install_lib.install_lib.run(self) @@ -109,12 +112,13 @@ class MyInstallLib(install_lib.install_lib): for directory in include_dirs: dest = join(self.install_dir, directory) if sys.version_info >= (3, 0): - exclude = {'invalid_encoded_data*', 'unknown_encoding*'} + exclude = {"invalid_encoded_data*", "unknown_encoding*"} else: exclude = set() shutil.rmtree(dest, ignore_errors=True) - shutil.copytree(directory, dest, - ignore=shutil.ignore_patterns(*exclude)) + shutil.copytree( + directory, dest, ignore=shutil.ignore_patterns(*exclude) + ) # override this since pip/easy_install attempt to byte compile test data # files, some of them being syntactically wrong by design, and this scares @@ -125,6 +129,7 @@ class MyInstallLib(install_lib.install_lib): if easy_install_lib: + class easy_install(easy_install_lib.easy_install): # override this since pip/easy_install attempt to byte compile # test data files, some of them being syntactically wrong by design, @@ -137,43 +142,47 @@ if easy_install_lib: def install(**kwargs): """setup entry point""" if USE_SETUPTOOLS: - if '--force-manifest' in sys.argv: - sys.argv.remove('--force-manifest') - packages = [modname] + get_packages(join(base_dir, 'pylint'), modname) + if "--force-manifest" in sys.argv: + sys.argv.remove("--force-manifest") + packages = [modname] + get_packages(join(base_dir, "pylint"), modname) if USE_SETUPTOOLS: if install_requires: - kwargs['install_requires'] = install_requires - kwargs['dependency_links'] = dependency_links - kwargs['entry_points'] = {'console_scripts': [ - 'pylint = pylint:run_pylint', - 'epylint = pylint:run_epylint', - 'pyreverse = pylint:run_pyreverse', - 'symilar = pylint:run_symilar', - ]} - kwargs['packages'] = packages - cmdclass = {'install_lib': MyInstallLib, - 'build_py': build_py} + kwargs["install_requires"] = install_requires + kwargs["dependency_links"] = dependency_links + kwargs["entry_points"] = { + "console_scripts": [ + "pylint = pylint:run_pylint", + "epylint = pylint:run_epylint", + "pyreverse = pylint:run_pyreverse", + "symilar = pylint:run_symilar", + ] + } + kwargs["packages"] = packages + cmdclass = {"install_lib": MyInstallLib, "build_py": build_py} if easy_install_lib: - cmdclass['easy_install'] = easy_install - return setup(name=distname, - version=__pkginfo__['version'], - license=__pkginfo__['license'], - description=__pkginfo__['description'], - long_description=long_description, - author=__pkginfo__['author'], - author_email=__pkginfo__['author_email'], - url=__pkginfo__['web'], - scripts=ensure_scripts(scripts), - classifiers=__pkginfo__['classifiers'], - data_files=data_files, - ext_modules=ext_modules, - cmdclass=cmdclass, - extras_require=extras_require, - test_suite='test', - python_requires='>=3.4.*', - setup_requires=['pytest-runner'], - tests_require=['pytest'], - **kwargs) - -if __name__ == '__main__': + cmdclass["easy_install"] = easy_install + return setup( + name=distname, + version=__pkginfo__["version"], + license=__pkginfo__["license"], + description=__pkginfo__["description"], + long_description=long_description, + author=__pkginfo__["author"], + author_email=__pkginfo__["author_email"], + url=__pkginfo__["web"], + scripts=ensure_scripts(scripts), + classifiers=__pkginfo__["classifiers"], + data_files=data_files, + ext_modules=ext_modules, + cmdclass=cmdclass, + extras_require=extras_require, + test_suite="test", + python_requires=">=3.4.*", + setup_requires=["pytest-runner"], + tests_require=["pytest"], + **kwargs + ) + + +if __name__ == "__main__": install() |