ParseError: Invalid type comment: (__main__:f.<locals>.A) -> None
まだ誰も着手していません。
評価
調査の方向性
提供されたスクリプトと pyannotate -w を使って失敗を再現します。pyannotate_tools/annotations/parse.py から始め、トレースバックにある tokenize と parse_type_comment を追い、型コメント <locals> がどのように処理されるかを調べます。アノテーションの生成時に例が ParseError を発生させなくなれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Given t-pyannotate.py:
from pyannotate_runtime import collect_types
collect_types.init_types_collection()
collect_types.start()
def c(obj):
pass
def f():
class A:
pass
c(A())
f()
collect_types.stop()
collect_types.dump_stats("type_info.json")
Produces:
[
{
"path": "t-pyannotate.py",
"line": 8,
"func_name": "c",
"type_comments": [
"(__main__:f.<locals>.A) -> None"
],
"samples": 1
},
{
"path": "t-pyannotate.py",
"line": 12,
"func_name": "f",
"type_comments": [
"() -> None"
],
"samples": 1
},
{
"path": "t-pyannotate.py",
"line": 13,
"func_name": "A",
"type_comments": [
"() -> None"
],
"samples": 1
}
]
Running pyannotate -w then crashes:
Traceback (most recent call last):
File "…/Vcs/pytest/.venv/bin/pyannotate", line 11, in <module>
load_entry_point('pyannotate', 'console_scripts', 'pyannotate')()
File "…/Vcs/pyannotate/pyannotate_tools/annotations/__main__.py", line 125, in main
data = generate_annotations_json_string(
File "…/Vcs/pyannotate/pyannotate_tools/annotations/main.py", line 60, in generate_annotations_json_string
signature = unify_type_comments(item.type_comments)
File "…/Vcs/pyannotate/pyannotate_tools/annotations/main.py", line 27, in unify_type_comments
arg_types, return_type = infer_annotation(type_comments)
File "…/Vcs/pyannotate/pyannotate_tools/annotations/infer.py", line 45, in infer_annotation
arg_types, return_type = parse_type_comment(comment)
File "…/Vcs/pyannotate/pyannotate_tools/annotations/parse.py", line 216, in parse_type_comment
return Parser(comment).parse()
File "…/Vcs/pyannotate/pyannotate_tools/annotations/parse.py", line 225, in __init__
self.tokens = tokenize(comment)
File "…/Vcs/pyannotate/pyannotate_tools/annotations/parse.py", line 193, in tokenize
raise ParseError(original)
pyannotate_tools.annotations.parse.ParseError: Invalid type comment: (__main__:f.<locals>.A) -> None
This is likely due to the "" in there I guess?
pyannotate b7f96ca (current master)
- 主要言語
- Python
- スター
- 1.4k
- フォーク
- 59
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dropbox/pyannotate のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
dropbox/pyannotate#124 · リアクション 3 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
dropbox/pyannotate#123 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
dropbox/pyannotate#115 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
dropbox/pyannotate#109 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
dropbox/pyannotate#103 · コメント 6 件 · リアクション 1 件 ·
dropbox/pyannotate の issue をすべて見る
似ている issue
-
dependencies feature github_actions good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
wemake-services/wemake-django-template#3149 ·
メンテナーはふだん 1 日以内に返信
-
[request] vsg/1.1.16オープンupstream update
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
conan-io/conan-center-index#31142 ·
メンテナーはふだん 1 日以内に返信
-
area:core bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
request-theme
難易度 2/5 1時間未満 初心者へのやさしさ 70/100
LizardByte/ThemerrDB#8877 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area/install-update comp/gateway P0 sweeper:risk-compatibility type/bug
難易度 2/5 1時間未満 初心者へのやさしさ 72/100
NousResearch/hermes-agent#135997 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信