本文整理汇总了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
示例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
示例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())