Skip to content

Commit f2946b2

Browse files
committed
Merge pull request #669 from JamesGuthrie/version
Add --version option
2 parents 235a504 + 26c880b commit f2946b2

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

mypy/version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = '0.2.0-dev'

scripts/mypy

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ from typing import List, Tuple
1414
from mypy import build
1515
from mypy.errors import CompileError
1616

17+
from mypy.version import __version__
18+
1719

1820
class Options:
1921
def __init__(self) -> None:
@@ -87,6 +89,7 @@ def process_options(args: List[str]) -> Tuple[str, str, Options]:
8789
"""
8890
options = Options()
8991
help = False
92+
ver = False
9093
while args and args[0].startswith('-'):
9194
if args[0] == '--verbose':
9295
options.build_flags.append(build.VERBOSE)
@@ -117,12 +120,18 @@ def process_options(args: List[str]) -> Tuple[str, str, Options]:
117120
elif args[0] == '--use-python-path':
118121
options.python_path = True
119122
args = args[1:]
123+
elif args[0] == '--version':
124+
ver = True
125+
args = args[1:]
120126
else:
121127
usage('Unknown option: {}'.format(args[0]))
122128

123129
if help:
124130
usage()
125131

132+
if ver:
133+
version()
134+
126135
if not args:
127136
usage('Missing target file or module')
128137

@@ -153,12 +162,16 @@ Optional arguments:
153162
-m mod type check module
154163
--verbose more verbose messages
155164
--use-python-path search for modules in sys.path of running Python
165+
--version show the current version information
156166
157167
Environment variables:
158168
MYPYPATH additional module search path
159169
""")
160170
sys.exit(2)
161171

172+
def version() -> None:
173+
sys.stdout.write("mypy {}\n".format(__version__))
174+
exit(0)
162175

163176
def fail(msg: str) -> None:
164177
sys.stderr.write('%s\n' % msg)

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
import sys
77

88
from distutils.core import setup
9+
from mypy.version import __version__
910

1011
if sys.version_info < (3, 2, 0):
1112
sys.stderr.write("ERROR: You need Python 3.2 or later to use mypy.\n")
1213
exit(1)
1314

14-
version = '0.2.0'
15+
version = __version__
1516
description = 'Optional static typing for Python'
1617
long_description = '''
1718
Mypy -- Optional Static Typing for Python

0 commit comments

Comments
 (0)