summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/source/internal/start-to-finish.rst15
-rw-r--r--docs/source/user/index.rst2
-rw-r--r--setup.cfg2
-rw-r--r--src/flake8/main/setuptools_command.py115
-rw-r--r--tests/unit/test_setuptools_command.py33
5 files changed, 0 insertions, 167 deletions
diff --git a/docs/source/internal/start-to-finish.rst b/docs/source/internal/start-to-finish.rst
index faed9bd..5e31083 100644
--- a/docs/source/internal/start-to-finish.rst
+++ b/docs/source/internal/start-to-finish.rst
@@ -47,21 +47,6 @@ both cases, however, you end up in :func:`flake8.main.cli.main`. This is the
primary way that users will end up starting Flake8. This function creates an
instance of |Application|.
-via Setuptools
---------------
-
-If you're invoking |Flake8| from your ``setup.py`` then you actually end up in
-:meth:`flake8.main.setuptools_command.Flake8.run`. This then collects the
-files that are included in the package information and creates an instance of
-|Application|.
-
-via Git or Mercurial
---------------------
-
-In both cases, they call their respective ``hook`` functions which create
-instances of |Application|.
-
-
Application Logic
=================
diff --git a/docs/source/user/index.rst b/docs/source/user/index.rst
index 5a24b21..90d5b14 100644
--- a/docs/source/user/index.rst
+++ b/docs/source/user/index.rst
@@ -8,8 +8,6 @@
- invoked via Python
-- called by Git or Mercurial on or around committing
-
This guide will cover all of these and the nuances for using |Flake8|.
.. note::
diff --git a/setup.cfg b/setup.cfg
index 0d3ab08..9103522 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -56,8 +56,6 @@ python_requires = >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*
where = src
[options.entry_points]
-distutils.commands=
- flake8 = flake8.main.setuptools_command:Flake8
console_scripts =
flake8 = flake8.main.cli:main
flake8.extension =
diff --git a/src/flake8/main/setuptools_command.py b/src/flake8/main/setuptools_command.py
deleted file mode 100644
index fde290e..0000000
--- a/src/flake8/main/setuptools_command.py
+++ /dev/null
@@ -1,115 +0,0 @@
-"""The logic for Flake8's integration with setuptools."""
-from distutils import log
-import os
-from typing import List, Tuple
-
-import setuptools
-
-from flake8.main import application as app
-
-UNSET = object()
-
-
-class Flake8(setuptools.Command):
- """Run Flake8 via setuptools/distutils for registered modules."""
-
- description = "Run Flake8 on modules registered in setup.py"
- # NOTE(sigmavirus24): If we populated this with a list of tuples, users
- # could do something like ``python setup.py flake8 --ignore=E123,E234``
- # but we would have to redefine it and we can't define it dynamically.
- # Since I refuse to copy-and-paste the options here or maintain two lists
- # of options, and since this will break when users use plugins that
- # provide command-line options, we are leaving this empty. If users want
- # to configure this command, they can do so through config files.
- user_options = [] # type: List[str]
-
- def initialize_options(self):
- """Override this method to initialize our application."""
- self.flake8 = app.Application()
- self.flake8.initialize([])
- options = self.flake8.option_manager.options
- for option in options:
- if option.parse_from_config:
- setattr(self, option.config_name, UNSET)
-
- def finalize_options(self):
- """Override this to parse the parameters."""
- options = self.flake8.option_manager.options
- for option in options:
- if option.parse_from_config:
- name = option.config_name
- value = getattr(self, name, UNSET)
- if value is UNSET:
- continue
- setattr(
- self.flake8.options,
- name,
- option.normalize_from_setuptools(value),
- )
-
- def package_files(self):
- """Collect the files/dirs included in the registered modules."""
- seen_package_directories = () # type: Tuple[str, ...]
- directories = self.distribution.package_dir or {}
- empty_directory_exists = "" in directories
- packages = self.distribution.packages or []
- for package in packages:
- package_directory = package
- if package in directories:
- package_directory = directories[package]
- elif empty_directory_exists:
- package_directory = os.path.join(
- directories[""], package_directory
- )
-
- # NOTE(sigmavirus24): Do not collect submodules, e.g.,
- # if we have:
- # - flake8/
- # - flake8/plugins/
- # Flake8 only needs ``flake8/`` to be provided. It will
- # recurse on its own.
- if package_directory.startswith(seen_package_directories):
- continue
-
- seen_package_directories += (package_directory + ".",)
- yield package_directory
-
- def module_files(self):
- """Collect the files listed as py_modules."""
- modules = self.distribution.py_modules or []
- filename_from = "{0}.py".format
- for module in modules:
- yield filename_from(module)
-
- def distribution_files(self):
- """Collect package and module files."""
- for package in self.package_files():
- yield package
-
- for module in self.module_files():
- yield module
-
- yield "setup.py"
-
- def run(self):
- """Run the Flake8 application."""
- self.flake8.run_checks(list(self.distribution_files()))
- self.flake8.formatter.start()
- self.flake8.report_errors()
- self.flake8.report_statistics()
- self.flake8.report_benchmarks()
- self.flake8.formatter.stop()
- try:
- self.flake8.exit()
- except SystemExit as e:
- # Cause system exit only if exit code is not zero (terminates
- # other possibly remaining/pending setuptools commands).
- if e.code:
- raise
- finally:
- self.announce(
- "WARNING: flake8 setuptools integration is deprecated and "
- "scheduled for removal in 4.x. For more information, see "
- "https://gitlab.com/pycqa/flake8/issues/544",
- log.WARN,
- )
diff --git a/tests/unit/test_setuptools_command.py b/tests/unit/test_setuptools_command.py
deleted file mode 100644
index 1c52b2a..0000000
--- a/tests/unit/test_setuptools_command.py
+++ /dev/null
@@ -1,33 +0,0 @@
-"""Module containing tests for the setuptools command integration."""
-import pytest
-from setuptools import dist
-
-from flake8.main import setuptools_command
-
-
-@pytest.fixture
-def distribution():
- """Create a setuptools Distribution object."""
- return dist.Distribution({
- 'name': 'foo',
- 'packages': [
- 'foo',
- 'foo.bar',
- 'foo_biz',
- ],
- })
-
-
-@pytest.fixture
-def command(distribution):
- """Create an instance of Flake8's setuptools command."""
- return setuptools_command.Flake8(distribution)
-
-
-def test_package_files_removes_submodules(command):
- """Verify that we collect all package files."""
- package_files = list(command.package_files())
- assert sorted(package_files) == [
- 'foo',
- 'foo_biz',
- ]