json_schema.py 文件源码

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

项目:fleaker 作者: croscon 项目源码 文件源码
def _get_schema(cls, schema):
        """Method that will fetch a Marshmallow schema flexibly.

        Args:
            schema (marshmallow.Schema|str): Either the schema class, an
                instance of a schema, or a Python path to a schema.

        Returns:
            marshmallow.Schema: The desired schema.

        Raises:
            TypeError: This is raised if the provided object isn't
                a Marshmallow schema.
        """
        if isinstance(schema, string_types):
            schema = cls._get_object_from_python_path(schema)

        if isclass(schema):
            schema = schema()

        if not isinstance(schema, Schema):
            raise TypeError("The schema must be a path to a Marshmallow "
                            "schema or a Marshmallow schema.")

        return schema
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号