From 4ab288d7dcb65d5c470374475921331f79b5423e Mon Sep 17 00:00:00 2001 From: yedpodtrzitko Date: Wed, 2 Aug 2017 00:46:52 +0200 Subject: [PATCH 1/2] add option to skip package checking --- mypy/build.py | 4 ++++ mypy/main.py | 1 + mypy/options.py | 2 ++ 3 files changed, 7 insertions(+) diff --git a/mypy/build.py b/mypy/build.py index 93d62e50cabb..ac778d1ccf01 100644 --- a/mypy/build.py +++ b/mypy/build.py @@ -1358,6 +1358,10 @@ def __init__(self, self.import_context = [] self.id = id or '__main__' self.options = manager.options.clone_for_module(self.id) + + if self.options.skip: + raise ModuleNotFound + if not path and source is None: file_id = id if id == 'builtins' and self.options.python_version[0] == 2: diff --git a/mypy/main.py b/mypy/main.py index ee8781f6d333..fdb7f4293085 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -625,6 +625,7 @@ def get_init_file(dir: str) -> Optional[str]: 'silent_imports': bool, 'almost_silent': bool, 'plugins': lambda s: [p.strip() for p in s.split(',')], + 'skip': bool, } SHARED_CONFIG_FILES = ('setup.cfg',) diff --git a/mypy/options.py b/mypy/options.py index 452d256c712e..a3a82c2acff8 100644 --- a/mypy/options.py +++ b/mypy/options.py @@ -34,6 +34,7 @@ class Options: "no_implicit_optional", "strict_optional", "disallow_untyped_decorators", + "skip", } OPTIONS_AFFECTING_CACHE = ((PER_MODULE_OPTIONS | {"quick_and_dirty", "platform"}) @@ -149,6 +150,7 @@ def __init__(self) -> None: self.shadow_file = None # type: Optional[Tuple[str, str]] self.show_column_numbers = False # type: bool self.dump_graph = False + self.skip = False def __eq__(self, other: object) -> bool: return self.__class__ == other.__class__ and self.__dict__ == other.__dict__ From 0bbfb78e4937f317629fafe1288caad8fc556fe5 Mon Sep 17 00:00:00 2001 From: yedpodtrzitko Date: Thu, 3 Aug 2017 23:13:25 +0200 Subject: [PATCH 2/2] add explanation into docs --- docs/source/config_file.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/source/config_file.rst b/docs/source/config_file.rst index 6d6ae156ba8a..dd5f456b1d38 100644 --- a/docs/source/config_file.rst +++ b/docs/source/config_file.rst @@ -187,6 +187,8 @@ overridden by the pattern sections matching the module name. - ``no_implicit_optional`` (Boolean, default false) changes the treatment of arguments with a default value of None by not implicitly making their type Optional +- ``skip`` (Boolean, default False) skip typechecking in given package. + Example *******