python_linter.py 文件源码

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

项目:sublime-text-3-packages 作者: nickjj 项目源码 文件源码
def get_module_version(cls):
        """
        Return the string version of the imported module, without any prefix/suffix.

        This method handles the common case where a module (or one of its parents)
        defines a __version__ string. For other cases, subclasses should override
        this method and return the version string.

        """

        if cls.module:
            module = cls.module

            while True:
                if isinstance(getattr(module, '__version__', None), str):
                    return module.__version__

                if hasattr(module, '__package__'):
                    try:
                        module = importlib.import_module(module.__package__)
                    except ImportError:
                        return None
        else:
            return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号