From f0f2ea7f4e3e536f2507703e350c89d0468feb31 Mon Sep 17 00:00:00 2001 From: Raphael Das Gupta Date: Fri, 13 Jan 2017 14:22:44 +0000 Subject: [PATCH 1/2] Force --version to be reproducible By ordering the plugins, --version becomes reproducible so that it continuously prints the same output (provided the plugins have not changed). Closes #297 --- src/flake8/options/manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/flake8/options/manager.py b/src/flake8/options/manager.py index b536907..90cfe46 100644 --- a/src/flake8/options/manager.py +++ b/src/flake8/options/manager.py @@ -245,7 +245,7 @@ class OptionManager(object): """Generate a comma-separated list of versions of plugins.""" return join_on.join( format_str % self.format_plugin(plugin) - for plugin in self.registered_plugins + for plugin in sorted(self.registered_plugins) ) def update_version_string(self): From c9ea51aa45a645857336b5a7645cebff3d9ece66 Mon Sep 17 00:00:00 2001 From: Ian Cordasco Date: Sat, 21 Jan 2017 14:14:59 -0600 Subject: [PATCH 2/2] Add test for reproducible --version strings And add a release note to document the change. --- docs/source/release-notes/3.3.0.rst | 11 ++++++++++- tests/unit/test_option_manager.py | 17 +++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/docs/source/release-notes/3.3.0.rst b/docs/source/release-notes/3.3.0.rst index af62f6b..2a22906 100644 --- a/docs/source/release-notes/3.3.0.rst +++ b/docs/source/release-notes/3.3.0.rst @@ -19,9 +19,14 @@ You can view the `3.3.0 milestone`_ on GitLab for more details. - Added unique error codes for all missing PyFlakes messages (14 new codes, see all :ref:`Error / Violation Codes `) -.. links +- Force ``flake8 --version`` to be repeatable between invocations. (See also + `GitLab#297`_) + +.. all links .. _3.3.0 milestone: https://gitlab.com/pycqa/flake8/milestones/16 + +.. issue links .. _GitLab#244: https://gitlab.com/pycqa/flake8/issues/244 .. _GitLab#251: @@ -30,5 +35,9 @@ You can view the `3.3.0 milestone`_ on GitLab for more details. https://gitlab.com/pycqa/flake8/issues/268 .. _GitLab#290: https://gitlab.com/pycqa/flake8/issues/290 +.. _GitLab#297: + https://gitlab.com/pycqa/flake8/issues/297 + +.. merge request links .. _GitLab!156: https://gitlab.com/pycqa/flake8/merge_requests/156 diff --git a/tests/unit/test_option_manager.py b/tests/unit/test_option_manager.py index 661b445..3f210ae 100644 --- a/tests/unit/test_option_manager.py +++ b/tests/unit/test_option_manager.py @@ -137,6 +137,23 @@ def test_generate_versions(optmanager): 'Testing 100: 0.0.0, Testing 101: 0.0.0, Testing 300: 0.0.0') +def test_plugins_are_sorted_in_generate_versions(optmanager): + """Verify we sort before joining strings in generate_versions.""" + optmanager.registered_plugins = [ + ('pyflakes', '1.5.0'), + ('mccabe', '0.7.0'), + ('pycodestyle', '2.2.0'), + ('flake8-docstrings', '0.6.1'), + ('flake8-bugbear', '2016.12.1'), + ] + assert (optmanager.generate_versions() == + 'flake8-bugbear: 2016.12.1, ' + 'flake8-docstrings: 0.6.1, ' + 'mccabe: 0.7.0, ' + 'pycodestyle: 2.2.0, ' + 'pyflakes: 1.5.0') + + def test_generate_versions_with_format_string(optmanager): """Verify a comma-separated string is generated of registered plugins.""" optmanager.registered_plugins.update([