mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-09 22:34:17 +00:00
Add python and platform details to --version
On Flake8 2.x we added the information about the implementation,
version, and operating system to the --version output to make helping
users easier. In short they can pretty simply just give us the output
from
flake8 --version
And we can get a lot of the information that we need.
This commit is contained in:
parent
2d3e277b1e
commit
c9fb680dff
3 changed files with 24 additions and 3 deletions
|
|
@ -236,8 +236,10 @@ class OptionManager(object):
|
||||||
|
|
||||||
def update_version_string(self):
|
def update_version_string(self):
|
||||||
"""Update the flake8 version string."""
|
"""Update the flake8 version string."""
|
||||||
self.parser.version = (self.version + ' (' +
|
self.parser.version = (
|
||||||
self.generate_versions() + ')')
|
self.version + ' (' + self.generate_versions() + ') ' +
|
||||||
|
utils.get_python_version()
|
||||||
|
)
|
||||||
|
|
||||||
def generate_epilog(self):
|
def generate_epilog(self):
|
||||||
"""Create an epilog with the version and name of each of plugin."""
|
"""Create an epilog with the version and name of each of plugin."""
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import fnmatch as _fnmatch
|
||||||
import inspect
|
import inspect
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
|
import platform
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
@ -290,3 +291,19 @@ def parameters_for(plugin):
|
||||||
parameters.pop('self', None)
|
parameters.pop('self', None)
|
||||||
|
|
||||||
return parameters
|
return parameters
|
||||||
|
|
||||||
|
|
||||||
|
def get_python_version():
|
||||||
|
"""Find and format the python implementation and version.
|
||||||
|
|
||||||
|
:returns:
|
||||||
|
Implementation name, version, and platform as a string.
|
||||||
|
:rtype:
|
||||||
|
str
|
||||||
|
"""
|
||||||
|
# The implementation isn't all that important.
|
||||||
|
try:
|
||||||
|
impl = platform.python_implementation() + " "
|
||||||
|
except AttributeError: # Python 2.5
|
||||||
|
impl = ''
|
||||||
|
return '%s%s on %s' % (impl, platform.python_version(), platform.system())
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import os
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from flake8 import utils
|
||||||
from flake8.options import manager
|
from flake8.options import manager
|
||||||
|
|
||||||
TEST_VERSION = '3.0.0b1'
|
TEST_VERSION = '3.0.0b1'
|
||||||
|
|
@ -162,7 +163,8 @@ def test_update_version_string(optmanager):
|
||||||
|
|
||||||
assert optmanager.version == TEST_VERSION
|
assert optmanager.version == TEST_VERSION
|
||||||
assert (optmanager.parser.version == TEST_VERSION + ' ('
|
assert (optmanager.parser.version == TEST_VERSION + ' ('
|
||||||
'Testing 100: 0.0.0, Testing 101: 0.0.0, Testing 300: 0.0.0)')
|
'Testing 100: 0.0.0, Testing 101: 0.0.0, Testing 300: 0.0.0) ' +
|
||||||
|
utils.get_python_version())
|
||||||
|
|
||||||
|
|
||||||
def test_generate_epilog(optmanager):
|
def test_generate_epilog(optmanager):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue