whatstyle.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:whatstyle 作者: mikr 项目源码 文件源码
def variants_for(self, option):
        # type: (Option) -> List[Style]

        def kvpairs(vs):
            # type: (Iterable[OptionValue]) -> List[Style]
            return stylevariants(stylename, vs)

        stylename = option_name(option)
        styletype = option_type(option)
        configs = option_configs(option)

        if configs:
            return kvpairs(configs)
        if styletype == 'bool':
            return kvpairs([True, False])
        if styletype == 'int':
            if stylename == 'column_limit':
                # Here we can get weird results, for example
                # in bottle_sqlalchemy.py is a constructor with
                # 8 arguments which are already split between two lines.
                # We find an optimum column limit of 126 because this
                # has less diff lines than putting each argument on a new
                # line. Maybe we should use a different diff metric.
                return kvpairs(self.column_limit_candidates)
            elif stylename == 'indent_width':
                return kvpairs([2, 4, 8])
            elif stylename == 'spaces_before_comment':
                return kvpairs(inclusiverange(1, 4))
            elif stylename.startswith('split_penalty'):
                # We avoid changing large integers whose purpose
                # is not exactly clear for the moment.
                pass
        return []

# ----------------------------------------------------------------------
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号