私が理解しているように、Python (2.5.2) は抽象クラスを実際にサポートしていません。このクラスが「参照されていない抽象クラス」であると pylint が不平を言うのはなぜですか? NotImplementedError
スローしたクラスに対してこれを行いますか?
私は各クラスを独自のファイルに持っているので、この場合、このメッセージを抑制するしかないと思いますが、別の方法があることを願っています.
"""Package Repository interface."""
class PackageRepository(object):
"""Package Repository interface."""
def __init__(self):
self.hello = "world"
def get_package(self, package_id):
"""
Get a package by ID.
"""
raise NotImplementedError( \
"get_package() method has not been implemented")
def get_packages(self):
"""
Get all packages.
"""
raise NotImplementedError( \
"get_packages() method has not been implemented")
def commit(self):
"""
Commit all changes.
"""
raise NotImplementedError( \
"commit() method has not been implemented")
def do_something(self):
"""
Doing something.
"""
return self.hello
編集
おそらく私は明確にする必要があります。私はこれが抽象クラスであることを認識しており、abstract キーワードを使用したいと思っていますが、Python では (少なくとも現在使用しているバージョンでは) 重要ではないことを理解しているため、面白い抽象トリックを行う必要はありません (ここにあるもののように)、単純に省略しました。
pylint がそれ自体が抽象クラスであるという事実を認識していることに驚きました。これが抽象クラスであると pylint が判断する理由は何ですか? NotImplementedError
どこかに放り出されるのをただ探しているだけですか?