Type checking with mypy
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 42/100
調査の方向性
提案されている py.typed マーカー、launch/launch/event_handler.py と launch/frontend/parser.py における mypy の指摘、および ament_pep257 を使用している既存の CI チェックを確認してください。まず、ament_mypy を現在のテスト構成にどのように組み込めるかを確認します。合意した型チェックの範囲が実装され、報告されたエラーなしで CI がそれを検証できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Bug report
I am sorry to open an issue in such short order, but as part of my work at Woven Planet, I'm trying to use the ROS2 launch system. Unfortunately, I have found that it type information is currently unusable from an external package, thus I'd like to improve it.
Required Info:
- Operating System:
- Ubuntu 18.04
- Installation type:
- Source
- Version or commit hash:
- 6783ca8
- DDS implementation:
- CycloneDDS
- Client library (if applicable):
- N/A
Steps to reproduce issue
- Create a snippet with this content:
import launch
context = launch.LaunchContext()
reveal_type(context)
- Install mypy
- Run the following:
MYPYPATH=$PATH_TO_WS/install/launch/lib/python3.8/site-packages/ mypy -m launch
(mypy does not use PYTHONPATH by default)
Expected behavior
test.py:4: note: Revealed type is 'launch.launch_context.LaunchContext'
Actual behavior
test.py:1: error: Cannot find implementation or library stub for module named 'launch'
test.py:1: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports
test.py:4: note: Revealed type is 'Any'
Feature request
Feature description
I'd like to make the type checking in launch (and potentially other ROS2 core libraries) a little bit stricter. This would allow to enforce a quality standard, and root out bugs at the base. It would also make the code easier to use from the outside, since type checking would prevent some common bugs in launch files, such as using a substitution where a condition is expected. Since type-checking is strictly opt-in, there would be no impact on the broader community.
Implementation considerations
- I have already implemented adding the
py.typedfile to mark thelaunchpackage as typed to the broader system, and can submit a PR promptly - However, there are many type-checking issues in the current codebase, including bugs. For example, mypy reported that this function does not have a return statement, contradicting its signature. Similarly, this statement has invalid type syntax. Probably someone meant
Tuple? In total mypy reports 224 errors in 47 files. - Thus, I think we should also add a CI test to check the type information using
mypy. This is I think very straightforward using ament_mypy in the same way that you are currently usingament_pep257and others.
I can take care of the above points, but I'd like to make sure that the maintainers agree with this approach before making a PR full of tiny changes.
Thank you very much!
- 主要言語
- Python
- スター
- 156
- フォーク
- 200
- 平均マージ
- 2日 11時間
- マージ済み PR(30日)
- 11
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ros2/launch のほかの issue
-
Use a relative target for the `latest` log symlink so it survives different absolute mount paths (host/Docker)対応中かも @Old-Ding が 139 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
ros2/launch#978 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Add OpaqueFunction to list at docs.ros.org再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンbug help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
メンテナーはふだん 1 日以内に返信
-
[launch_testing] pytest>8.1 dropped the legacy "path" argument from its internal hooks on humble対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
ui
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
ARTPARK-SAHAI-ORG/calibrate-frontend#919 ·
メンテナーはふだん 1 日以内に返信
-
CI: MSYS2 jobs fail — mingw python3 package renamed upstream to python対応中かも @ronaldtse が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
pydantic/pytest-examples#102 · コメント 1 件 ·