Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 强制子类实现父方法pylance_Python_Visual Studio Code_Pylance - Fatal编程技术网

Python 强制子类实现父方法pylance

Python 强制子类实现父方法pylance,python,visual-studio-code,pylance,Python,Visual Studio Code,Pylance,在我编写代码时,是否有办法对未实现的方法发出pylance警告 在运行时,我们可以使用raisenotimplementederror确保每个子类在调用父类方法之前都重写它 class blueprint: def methodA(self): raise NotImplementedError class myClass(blueprint): def methodB(self): pass myInstance = myClass()

在我编写代码时,是否有办法对未实现的方法发出pylance警告

在运行时,我们可以使用
raisenotimplementederror
确保每个子类在调用父类方法之前都重写它

class blueprint:
    def methodA(self):
        raise NotImplementedError

class myClass(blueprint):
      def methodB(self):
        pass

myInstance = myClass()
myInstance.methodA() #raises error at runtime, I want this to show error or warning before runtime

因为我可能不会在每个阶段测试应用程序的每个部分。如果我在运行时没有调用未实现的方法,我想确保它会通知我,甚至

编写一个执行此分析的PyLint插件