From 53c1ec7acbd30df29fd7f5272667f651261ce25e Mon Sep 17 00:00:00 2001 From: Remigiusz Modrzejewski Date: Tue, 4 Nov 2014 10:24:50 +0000 Subject: [PATCH 1/3] Mention pip in Quick start. --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2c8de698f5b7..f5ed522d1eef 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,12 @@ For other Linux flavors, OS X and Windows, packages are available at Quick start ----------- -If you have git, first clone the mypy git repository: +Mypy can be installed from pip: + + $ pip install mypy-lang + +If you want to contribute and have git, +first clone the mypy git repository: $ git clone https://github.com/JukkaL/mypy.git From 6230e3f9680b7e0056593bb9f9ae5bbdbf960a58 Mon Sep 17 00:00:00 2001 From: Remigiusz Modrzejewski Date: Tue, 4 Nov 2014 23:25:16 +0000 Subject: [PATCH 2/3] Introducing --python-path flag to search running Python's sys.path for modules. --- mypy/build.py | 12 +++++++++--- scripts/mypy | 12 +++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/mypy/build.py b/mypy/build.py index 9b1dec06e2f8..1d515ac9caeb 100644 --- a/mypy/build.py +++ b/mypy/build.py @@ -91,7 +91,8 @@ def build(program_path: str, pyversion: int = 3, custom_typing_module: str = None, html_report_dir: str = None, - flags: List[str] = None) -> BuildResult: + flags: List[str] = None, + python_path: bool = False) -> BuildResult: """Build a mypy program. A single call to build performs parsing, semantic analysis and optionally @@ -122,7 +123,7 @@ def build(program_path: str, data_dir = default_data_dir(bin_dir) # Determine the default module search path. - lib_path = default_lib_path(data_dir, target, pyversion) + lib_path = default_lib_path(data_dir, target, pyversion, python_path) if TEST_BUILTINS in flags: # Use stub builtins (to speed up test cases and to make them easier to @@ -191,7 +192,8 @@ def default_data_dir(bin_dir: str) -> str: raise RuntimeError("Broken installation: can't determine base dir") -def default_lib_path(data_dir: str, target: int, pyversion: int) -> List[str]: +def default_lib_path(data_dir: str, target: int, pyversion: int, + python_path:bool) -> List[str]: """Return default standard library search paths.""" # IDEA: Make this more portable. path = List[str]() @@ -218,6 +220,10 @@ def default_lib_path(data_dir: str, target: int, pyversion: int) -> List[str]: if sys.platform != 'win32': path.append('/usr/local/lib/mypy') + # Contents of Python's sys.path go last, to prefer the stubs + if python_path: + path.extend(sys.path) + return path diff --git a/scripts/mypy b/scripts/mypy index f4b202a59cbc..6fbfb374ce3e 100755 --- a/scripts/mypy +++ b/scripts/mypy @@ -23,6 +23,7 @@ class Options: self.pyversion = 3 self.custom_typing_module = None # type: str self.html_report_dir = None # type: str + self.python_path = False def main() -> None: @@ -73,7 +74,8 @@ def type_check_only(path: str, module: str, bin_dir: str, options: Options) -> N pyversion=options.pyversion, custom_typing_module=options.custom_typing_module, html_report_dir=options.html_report_dir, - flags=options.build_flags) + flags=options.build_flags, + python_path=options.python_path) def process_options(args: List[str]) -> Tuple[str, str, Options]: @@ -112,6 +114,9 @@ def process_options(args: List[str]) -> Tuple[str, str, Options]: options.html_report_dir = args[1] options.build_flags.append('html-report') args = args[2:] + elif args[0] == '--python-path': + options.python_path = True + args = args[1:] else: usage('Unknown option: {}'.format(args[0])) @@ -124,6 +129,10 @@ def process_options(args: List[str]) -> Tuple[str, str, Options]: if args[1:]: usage('Extra argument: {}'.format(args[1])) + if options.python_path and options.pyversion == 2: + usage('--py2 specified, ' + 'but --python_path will search in sys.path of Python 3') + return args[0], None, options @@ -143,6 +152,7 @@ Optional arguments: --html-report dir generate a HTML report of type precision under dir/ -m mod type check module --verbose more verbose messages + --python_path search for modules in sys.path of running Python Environment variables: MYPYPATH additional module search path From a01ae10eb7bde856692ee501f7f30433152a1523 Mon Sep 17 00:00:00 2001 From: Remigiusz Modrzejewski Date: Sat, 22 Nov 2014 10:03:23 +0000 Subject: [PATCH 3/3] Changing the flag name --python-path to --use-python-path. --- scripts/mypy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/mypy b/scripts/mypy index 6fbfb374ce3e..0c91bcca4fa7 100755 --- a/scripts/mypy +++ b/scripts/mypy @@ -114,7 +114,7 @@ def process_options(args: List[str]) -> Tuple[str, str, Options]: options.html_report_dir = args[1] options.build_flags.append('html-report') args = args[2:] - elif args[0] == '--python-path': + elif args[0] == '--use-python-path': options.python_path = True args = args[1:] else: @@ -131,7 +131,7 @@ def process_options(args: List[str]) -> Tuple[str, str, Options]: if options.python_path and options.pyversion == 2: usage('--py2 specified, ' - 'but --python_path will search in sys.path of Python 3') + 'but --use-python-path will search in sys.path of Python 3') return args[0], None, options @@ -152,7 +152,7 @@ Optional arguments: --html-report dir generate a HTML report of type precision under dir/ -m mod type check module --verbose more verbose messages - --python_path search for modules in sys.path of running Python + --use-python-path search for modules in sys.path of running Python Environment variables: MYPYPATH additional module search path