LoginSignup
8
10

More than 1 year has passed since last update.

PyCharm備忘録

Last updated at Posted at 2019-06-10

Settings

Inspections

メソッド名や変数名に日本語を使用しても、警告が出ないようにする。

「Non-ASCII identifier error」という警告を無効化する

docstringのformatを変更

Setting -> Tools -> Python Integrated Tools -> Docstring format
デフォルトはreStructuredTextです。

image.png

システムメニュにPyCharmを追加(Ubuntu版?)

Toos Menu -> 「Create DeskTop Entry」で、システムメニュにPyCharmを追加できます。

image.png

Run/Debug Configurations

テストメソッドの作業ディレクトリを変更する

テストメソッドの作業ディレクトリは、デフォルトではプロジェクト配下のtestsディレクトリです。
作業ディレクトリを変更する場合は、「Run/Debug Configurations」でダイアログを開き、 「Templates -> Python tests -> pytest」の「Working direcotry」を指定します。

image.png

Shortcuts

コードブロックの先頭と終わりに、ショートカットキーで移動する

  • Ctrl + [ :コードブロックの先頭に移動
  • Ctrl + ]:コードブロックの終了に移動

その他

Python Consoleで str.*find*?を入力したときの結果がIPythonと異なる

IPythonでの結果
str.find
str.rfind
PythonConsoleでの結果
In [0]: str.*find*?
 .....:
 .....:
 .....: 

入力が続いていると判断されて、入力を終了させることができませんでした。
https://youtrack.jetbrains.com/issue/PY-30712

「Method 'xxx' may be static」という警告が出る理由

image

インスタンスメソッドがselfを参照していないと、この警告がでます。

class Sample:
    val = 100
    def hoge(self, x):
        # 「Method `hoge` may be `static`」という警告発生
        return x * x
        # 以下のように`self`を参照すれば、警告は出ない
        # return x * x * self.val

8
10
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
8
10