質問

ですが、コンストラクタ、およびプログラムは、メソッドの呼び出し、PyCharm IDEでは良い分析が私のソースコード、コーヒーに飽きたら寿司にどのようなタイプの各変数です。私のような場合もあるので食コード補完、パラメータ情報、ちょっと警告さんのアクセスする属性をお使いになれません。

しかしパラメータを使用方法を選んでください。このコード補完dropdownsを表示できないので、何もないタイプのパラメータとなります。このコード解析できない探しの下方修正を発表している。

class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age

peasant = Person("Dennis", 37)
# PyCharm knows that the "peasant" variable is of type Person
peasant.dig_filth()   # shows warning -- Person doesn't have a dig_filth method

class King:
    def repress(self, peasant):
        # PyCharm has no idea what type the "peasant" parameter should be
        peasant.knock_over()   # no warning even though knock_over doesn't exist

King().repress(peasant)
# Even if I call the method once with a Person instance, PyCharm doesn't
# consider that to mean that the "peasant" parameter should always be a Person

その一定額です。その他のコートルーパスもそのパラメータとします。だが私のメソッドのパパラメータのタイプ、 pygame.Surface, 私にできることを示すためにPyCharm、なんとかなることができるってあえぐ者はみな、私のところの Surface's属性コード-ドロップダウンが完了、警告が私の間違った方法です。

があるので、日本語訳を見てもわかりませんPyCharmをヒント"ということをpsst、このパラメータへのタイプX"?(恐らく、精神的言語"このパラメータはquackのようにX"?いきます。)


編集: CrazyCoderの答えは、以下のリックを達成しています。更新人の私にはたい方の概要をこちらでは:

class King:
    def repress(self, peasant):
        """
        Exploit the workers by hanging on to outdated imperialist dogma which
        perpetuates the economic and social differences in our society.

        @type peasant: Person
        @param peasant: Person to repress.
        """
        peasant.knock_over()   # Shows a warning. And there was much rejoicing.

該当部分には、 @type peasant: Person ラインのdocstring.

いつものファイル>設定>Pythonの統合ツールおよび設定"Docstringフォーマット"を"Epytext"、PyCharmのビュー>速いの文書のルックアップとかプリントのパラメータ情報だけでなく印刷すべての@-ラインをいたします。

役に立ちましたか?

解決

されませんのでご了承ください特殊文書形式手法およびこれらのパラメータでPyCharmを知ることができます。最近のPyCharm版 を持doc形式.

例えば、PyCharm抽出物の種類から @paramスタイルのコメント.

参照 reStructuredTextdocstring条約 (PEP257).

別のオプションをPython3アンソロジー。

ください を参照して、PyCharm文書課 詳細については、http://wwwサンプル。

他のヒント

ご利用の場合はPython3.0以上などでもお使いいただけますの注釈機能とパラメータ。PyCharmは解釈するこの型の引数または戻り値について:

class King:
    def repress(self, peasant: Person) -> bool:
        peasant.knock_over() # Shows a warning. And there was much rejoicing.

        return peasant.badly_hurt() # Lets say, its not known from here that this method will always return a bool

このは非公開の方法、要らないdocstring.加えて、注釈によりアクセスできるコード:

>>> King.repress.__annotations__
{'peasant': <class '__main__.Person'>, 'return': <class 'bool'>}

更新:としての PEP484, して受け入れのためのPythonの3.5つもの公式大会指定の引数と戻り値の型を用いたアンソロジー。

PyCharm抽出物の種類から@型pydoc文字列になります。 見PyCharm docs こちらのこちらの, は、 Epydoc docs.この"遺産"のPyCharmれのものはよくないという欠けも可能です。

class King:
    def repress(self, peasant):
        """
        Exploit the workers by hanging on to outdated imperialist dogma which
        perpetuates the economic and social differences in our society.

        @type peasant: Person
        @param peasant: Person to repress.
        """
        peasant.knock_over()   # Shows a warning. And there was much rejoicing.

該当部分には、 @type peasant: Person ラインのdocstring.

私の意図はないが盗点からCrazyCoderの質問によってそのポイント。うと思ったんですけの単純な回答は、'answer'スロットに実装されていません。

を使用していPyCharmプロ2016.1書py2.6-2.7コード、およびその利用reStructuredTextっきの種類によりsuccint方法:

class Replicant(object):
    pass


class Hunter(object):
    def retire(self, replicant):
        """ Retire the rogue or non-functional replicant.
        :param Replicant replicant: the replicant to retire.
        """
        replicant.knock_over()  # Shows a warning.

参照: https://www.jetbrains.com/help/pycharm/2016.1/type-hinting-in-pycharm.html#legacy

また主張するためのタイプ、Pycharmは推測す:

def my_function(an_int):
    assert isinstance(an_int, int)
    # Pycharm now knows that an_int is of type int
    pass
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top