0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

pythonの__init__.py で PEP8のF401が出てしまう対応

Posted at

課題

packageのために、 app/__init__.py に 以下のようなコードを書くと PEP8 の F401に引っかかる

from .hoge import Hoge

対策

以下のように __all__ を使った記述をするとF401とならない

from .hoge import Hoge

__all__ = ('Hoge',)

__all__ って何?

all という名前のリストが定義されていれば、 from package import * が現れたときに import すべきモジュール名のリストとして使う、というものです。

参照

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?