当前位置: 首页>>代码示例>>Python>>正文


Python Options.snapshot方法代码示例

本文整理汇总了Python中mypy.options.Options.snapshot方法的典型用法代码示例。如果您正苦于以下问题:Python Options.snapshot方法的具体用法?Python Options.snapshot怎么用?Python Options.snapshot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mypy.options.Options的用法示例。


在下文中一共展示了Options.snapshot方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: daemonize

# 需要导入模块: from mypy.options import Options [as 别名]
# 或者: from mypy.options.Options import snapshot [as 别名]
    def daemonize(options: Options,
                  status_file: str,
                  timeout: Optional[int] = None,
                  log_file: Optional[str] = None) -> int:
        """Create the daemon process via "dmypy daemon" and pass options via command line

        When creating the daemon grandchild, we create it in a new console, which is
        started hidden. We cannot use DETACHED_PROCESS since it will cause console windows
        to pop up when starting. See
        https://github.com/python/cpython/pull/4150#issuecomment-340215696
        for more on why we can't have nice things.

        It also pickles the options to be unpickled by mypy.
        """
        command = [sys.executable, '-m', 'mypy.dmypy', '--status-file', status_file, 'daemon']
        pickeled_options = pickle.dumps((options.snapshot(), timeout, log_file))
        command.append('--options-data="{}"'.format(base64.b64encode(pickeled_options).decode()))
        info = STARTUPINFO()
        info.dwFlags = 0x1  # STARTF_USESHOWWINDOW aka use wShowWindow's value
        info.wShowWindow = 0  # SW_HIDE aka make the window invisible
        try:
            subprocess.Popen(command,
                             creationflags=0x10,  # CREATE_NEW_CONSOLE
                             startupinfo=info)
            return 0
        except subprocess.CalledProcessError as e:
            return e.returncode
开发者ID:python,项目名称:mypy,代码行数:29,代码来源:dmypy_server.py

示例2: __init__

# 需要导入模块: from mypy.options import Options [as 别名]
# 或者: from mypy.options.Options import snapshot [as 别名]
    def __init__(self, options: Options,
                 status_file: str,
                 timeout: Optional[int] = None) -> None:
        """Initialize the server with the desired mypy flags."""
        self.options = options
        # Snapshot the options info before we muck with it, to detect changes
        self.options_snapshot = options.snapshot()
        self.timeout = timeout
        self.fine_grained_manager = None  # type: Optional[FineGrainedBuildManager]

        if os.path.isfile(status_file):
            os.unlink(status_file)

        self.fscache = FileSystemCache()

        options.incremental = True
        options.fine_grained_incremental = True
        options.show_traceback = True
        if options.use_fine_grained_cache:
            # Using fine_grained_cache implies generating and caring
            # about the fine grained cache
            options.cache_fine_grained = True
        else:
            options.cache_dir = os.devnull
        # Fine-grained incremental doesn't support general partial types
        # (details in https://github.com/python/mypy/issues/4492)
        options.local_partial_types = True
        self.status_file = status_file
开发者ID:python,项目名称:mypy,代码行数:30,代码来源:dmypy_server.py

示例3: test_coherence

# 需要导入模块: from mypy.options import Options [as 别名]
# 或者: from mypy.options.Options import snapshot [as 别名]
 def test_coherence(self) -> None:
     options = Options()
     _, parsed_options = process_options([], require_targets=False)
     # FIX: test this too. Requires changing working dir to avoid finding 'setup.cfg'
     options.config_file = parsed_options.config_file
     assert_equal(options.snapshot(), parsed_options.snapshot())
开发者ID:Michael0x2a,项目名称:mypy,代码行数:8,代码来源:testargs.py


注:本文中的mypy.options.Options.snapshot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。