osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

# type: a


On Sun, 15 Sep 2019 at 16:53, Hongyi Zhao <hongyi.zhao at gmail.com> wrote:
>
> Hi,
>
> In pycharm? when I commented out the following line:
>
> # type: a
>
> The pycharm still told me that:
>
> Unresolved reference 'a'

PyCharm interprets PEP 484 type annotations and type comments, as well
as PEP 526 variable annotations. The comment you wrote is a type
comment that says 'a' is the expected type of something. The 'type:'
part is special here, `# foo: a` won?t trigger this warning. PyCharm
expects stuff in type comments to exist, because otherwise, there?s no
way to know what type you mean.

Type comments are now best replaced by Python 3.6+ variable
annotations, but the comments are still valid, and can be used in some
contexts where annotations are not supported.

https://www.python.org/dev/peps/pep-0484/#type-comments

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16