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


Python Options.incremental方法代码示例

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


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

示例1: parse_options

# 需要导入模块: from mypy.options import Options [as 别名]
# 或者: from mypy.options.Options import incremental [as 别名]
    def parse_options(self, program_text: str, testcase: DataDrivenTestCase,
                      incremental_step: int) -> Options:
        options = Options()
        flags = re.search('# flags: (.*)$', program_text, flags=re.MULTILINE)
        if incremental_step > 1:
            flags2 = re.search('# flags{}: (.*)$'.format(incremental_step), program_text,
                               flags=re.MULTILINE)
            if flags2:
                flags = flags2

        flag_list = None
        if flags:
            flag_list = flags.group(1).split()
            targets, options = process_options(flag_list, require_targets=False)
            if targets:
                raise RuntimeError('Specifying targets via the flags pragma is not supported.')
        else:
            options = Options()

        # Allow custom python version to override testcase_pyversion
        if (not flag_list or
                all(flag not in flag_list for flag in ['--python-version', '-2', '--py2'])):
            options.python_version = testcase_pyversion(testcase.file, testcase.name)

        options.use_builtins_fixtures = True
        options.show_traceback = True
        options.incremental = True

        return options
开发者ID:greatmazinger,项目名称:mypy,代码行数:31,代码来源:testdmypy.py

示例2: __init__

# 需要导入模块: from mypy.options import Options [as 别名]
# 或者: from mypy.options.Options import incremental [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: mypy_options

# 需要导入模块: from mypy.options import Options [as 别名]
# 或者: from mypy.options.Options import incremental [as 别名]
def mypy_options(stubgen_options: Options) -> MypyOptions:
    """Generate mypy options using the flag passed by user."""
    options = MypyOptions()
    options.follow_imports = 'skip'
    options.incremental = False
    options.ignore_errors = True
    options.semantic_analysis_only = True
    options.python_version = stubgen_options.pyversion
    return options
开发者ID:python,项目名称:mypy,代码行数:11,代码来源:stubgen.py

示例4: build_dir

# 需要导入模块: from mypy.options import Options [as 别名]
# 或者: from mypy.options.Options import incremental [as 别名]
def build_dir(target_dir: str) -> Tuple[List[str], BuildManager, Graph]:
    sources = expand_dir(target_dir)
    options = Options()
    options.incremental = True
    options.show_traceback = True
    options.cache_dir = os.devnull
    try:
        result = build.build(sources=sources,
                             options=options)
    except CompileError as e:
        # TODO: We need a manager and a graph in this case as well
        assert False, str('\n'.join(e.messages))
        return e.messages, None, None
    return result.errors, result.manager, result.graph
开发者ID:greatmazinger,项目名称:mypy,代码行数:16,代码来源:finegrained.py

示例5: build

# 需要导入模块: from mypy.options import Options [as 别名]
# 或者: from mypy.options.Options import incremental [as 别名]
 def build(self, source: str) -> Tuple[List[str], Optional[BuildManager], Dict[str, State]]:
     options = Options()
     options.incremental = True
     options.use_builtins_fixtures = True
     options.show_traceback = True
     main_path = os.path.join(test_temp_dir, 'main')
     with open(main_path, 'w') as f:
         f.write(source)
     try:
         result = build.build(sources=[BuildSource(main_path, None, None)],
                              options=options,
                              alt_lib_path=test_temp_dir)
     except CompileError as e:
         # TODO: Is it okay to return None?
         return e.messages, None, {}
     return result.errors, result.manager, result.graph
开发者ID:greatmazinger,项目名称:mypy,代码行数:18,代码来源:testmerge.py

示例6: build

# 需要导入模块: from mypy.options import Options [as 别名]
# 或者: from mypy.options.Options import incremental [as 别名]
 def build(self, source: str) -> Optional[BuildResult]:
     options = Options()
     options.incremental = True
     options.fine_grained_incremental = True
     options.use_builtins_fixtures = True
     options.show_traceback = True
     options.python_version = PYTHON3_VERSION
     main_path = os.path.join(test_temp_dir, 'main')
     with open(main_path, 'w', encoding='utf8') as f:
         f.write(source)
     try:
         result = build.build(sources=[BuildSource(main_path, None, None)],
                              options=options,
                              alt_lib_path=test_temp_dir)
     except CompileError:
         # TODO: Is it okay to return None?
         return None
     return result
开发者ID:Michael0x2a,项目名称:mypy,代码行数:20,代码来源:testmerge.py

示例7: __init__

# 需要导入模块: from mypy.options import Options [as 别名]
# 或者: from mypy.options.Options import incremental [as 别名]
    def __init__(self, options: Options,
                 timeout: Optional[int] = None,
                 alt_lib_path: Optional[str] = None) -> None:
        """Initialize the server with the desired mypy flags."""
        self.options = options
        self.timeout = timeout
        self.alt_lib_path = alt_lib_path
        self.fine_grained_manager = None  # type: Optional[FineGrainedBuildManager]

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

        options.incremental = True
        options.fine_grained_incremental = True
        options.show_traceback = True
        if options.use_fine_grained_cache:
            options.cache_fine_grained = True  # set this so that cache options match
        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
开发者ID:sixolet,项目名称:mypy,代码行数:24,代码来源:dmypy_server.py

示例8: process_options

# 需要导入模块: from mypy.options import Options [as 别名]
# 或者: from mypy.options.Options import incremental [as 别名]

#.........这里部分代码省略.........
    add_invertible_flag('--disallow-untyped-calls', default=False, strict_flag=True,
                        help="disallow calling functions without type annotations"
                        " from functions with type annotations")
    add_invertible_flag('--disallow-untyped-defs', default=False, strict_flag=True,
                        help="disallow defining functions without type annotations"
                        " or with incomplete type annotations")
    add_invertible_flag('--disallow-incomplete-defs', default=False, strict_flag=True,
                        help="disallow defining functions with incomplete type annotations")
    add_invertible_flag('--check-untyped-defs', default=False, strict_flag=True,
                        help="type check the interior of functions without type annotations")
    add_invertible_flag('--disallow-subclassing-any', default=False, strict_flag=True,
                        help="disallow subclassing values of type 'Any' when defining classes")
    add_invertible_flag('--warn-incomplete-stub', default=False,
                        help="warn if missing type annotation in typeshed, only relevant with"
                        " --check-untyped-defs enabled")
    add_invertible_flag('--disallow-untyped-decorators', default=False, strict_flag=True,
                        help="disallow decorating typed functions with untyped decorators")
    add_invertible_flag('--warn-redundant-casts', default=False, strict_flag=True,
                        help="warn about casting an expression to its inferred type")
    add_invertible_flag('--no-warn-no-return', dest='warn_no_return', default=True,
                        help="do not warn about functions that end without returning")
    add_invertible_flag('--warn-return-any', default=False, strict_flag=True,
                        help="warn about returning values of type Any"
                             " from non-Any typed functions")
    add_invertible_flag('--warn-unused-ignores', default=False, strict_flag=True,
                        help="warn about unneeded '# type: ignore' comments")
    add_invertible_flag('--warn-unused-configs', default=False, strict_flag=True,
                        help="warn about unused '[mypy-<pattern>]' config sections")
    add_invertible_flag('--show-error-context', default=False,
                        dest='show_error_context',
                        help='Precede errors with "note:" messages explaining context')
    add_invertible_flag('--no-implicit-optional', default=False, strict_flag=True,
                        help="don't assume arguments with default values of None are Optional")
    parser.add_argument('-i', '--incremental', action='store_true',
                        help="enable module cache, (inverse: --no-incremental)")
    parser.add_argument('--no-incremental', action='store_false', dest='incremental',
                        help=argparse.SUPPRESS)
    parser.add_argument('--quick-and-dirty', action='store_true',
                        help="use cache even if dependencies out of date "
                        "(implies --incremental)")
    parser.add_argument('--cache-dir', action='store', metavar='DIR',
                        help="store module cache info in the given folder in incremental mode "
                        "(defaults to '{}')".format(defaults.CACHE_DIR))
    parser.add_argument('--cache-fine-grained', action='store_true',
                        help="include fine-grained dependency information in the cache")
    parser.add_argument('--skip-version-check', action='store_true',
                        help="allow using cache written by older mypy version")
    add_invertible_flag('--strict-optional', default=False, strict_flag=True,
                        help="enable experimental strict Optional checks")
    parser.add_argument('--strict-optional-whitelist', metavar='GLOB', nargs='*',
                        help="suppress strict Optional errors in all but the provided files "
                        "(experimental -- read documentation before using!).  "
                        "Implies --strict-optional.  Has the undesirable side-effect of "
                        "suppressing other errors in non-whitelisted files.")
    parser.add_argument('--junit-xml', help="write junit.xml to the given file")
    parser.add_argument('--pdb', action='store_true', help="invoke pdb on fatal error")
    parser.add_argument('--show-traceback', '--tb', action='store_true',
                        help="show traceback on fatal error")
    parser.add_argument('--stats', action='store_true', dest='dump_type_stats', help="dump stats")
    parser.add_argument('--inferstats', action='store_true', dest='dump_inference_stats',
                        help="dump type inference stats")
    parser.add_argument('--custom-typing', metavar='MODULE', dest='custom_typing_module',
                        help="use a custom typing module")
    parser.add_argument('--custom-typeshed-dir', metavar='DIR',
                        help="use the custom typeshed in DIR")
    parser.add_argument('--scripts-are-modules', action='store_true',
开发者ID:sixolet,项目名称:mypy,代码行数:70,代码来源:main.py


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