special support for types from importlib.import_module and pkgutil.resolve_name with Literal arguments
オープン
まだ誰も着手していません。
feature
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Note: if you are reporting a wrong signature of a function or a class in
the standard library, then the typeshed tracker is better suited
for this report: https://github.com/python/typeshed/issues
Please provide more information to help us understand the issue:
- Are you reporting a bug, or opening a feature request? Feature
- Please insert below the code you are checking with mypy,
or a mock-up repro if the source is private. We would appreciate
if you try to simplify your case to a minimal repro.
def get_mock_module(v: Literal["mock"] | Literal["unittest.mock"]) -> ...:
return pkgutils.resolve_name(v)
- What is the actual behavior/output? Any
- What is the behavior/output you expect? Module["mock"] | Module["unittest.mock"]
- What are the versions of mypy and Python you are using? git master
Do you see the same issue after installing mypy from Git master? yes - What are the mypy flags you are using? (For example --strict-optional)
--strict
I think https://github.com/python/mypy/issues/5059 was closed because it was opened as a bug rather than a feature request
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、mypy --strict を使って例を再現し、Literal 引数が渡された場合の importlib.import_module と pkgutil.resolve_name に焦点を当てます。mypy が現在これらの呼び出しをどのように解析しているかを追跡します。完了条件は、例がエラーなしで Module["mock"] | Module["unittest.mock"] と推論されることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100