VS 代码显示“继承‘Base’,它不是一个类”作为错误消息,给出以下内容:
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Integer , String , Column
Base = declarative_base()
class Socio(Base):
__tablename__ = 'socios'
id = Column(Integer, autoincrement = True , primary_key = True)
dni = Column(Integer , unique = True)
nombre = Column(String(250))
apellido= Column(String(250))
为什么会发生这种情况?我该如何修复它?
Inheriting 'Base', which is not a class
实际上并不是一个错误。
相反,它是来自 Microsoft 的 Python 语言服务器的静态分析结果(该服务器又严重依赖于pylint https://www.pylint.org)进行此类分析。它并不总是准确的:如果一个类是动态生成并由函数返回的(就像这里的情况),静态检查工具可能无法正确理解它的类型。
如中所述microsoft/python-language-server#1390 https://github.com/microsoft/python-language-server/issues/1390,可以通过以下设置更改来禁用此功能:
"python.analysis.disabled": [
"inherit-non-class"
],
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)