mypy does not show error in excluded folder when PYTHONPATH set
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
調査の方向性
excluded_folder/excluded.py と included_folder/included.py を含む再現用のパッケージレイアウトから始め、次に PYTHONPATH=. の有無による 2 つの mypy コマンドを比較します。--exclude とインポートされたモジュールがどのように検出されるかを追跡します。PYTHONPATH=. を指定した呼び出しで excluded.py 内の互換性のない戻り値が報告され、両方のコマンドをカバーするリグレッションテストがあれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Bug Report
As far as I understand, when I use the exclude setting for some folder mypy should still show errors in these packages when imported, because of the follow imports logic. However, if I set the PYTHONPATH to the current working directory, it does not show these errors anymore.
To Reproduce
Here is the folder structure:
src/
|--excluded_folder/
| |-- excluded.py
| |-- __init__.py
|--included_folder/
|-- included.py
|-- __init__.py
The contents of the file excluded.py are as follows:
def function() -> str: # obviously wrong return type
return 5
File included.py looks like so:
from excluded_folder.excluded import function
print(function)
Now, if i run mypy like so, with the setting to exclude the excluded folder, it reports this:
$ mypy --strict --exclude excluded_folder src
src/excluded_folder/excluded.py:3: error: Incompatible return value type (got "int", expected "str") [return-value]
Found 1 error in 1 file (checked 2 source files)
This is what i would expect. It still shows the errors in the file, although excluded.
But if i run mypy with PYTHONPATH set to the current working directory, it does not show any error anymore:
% PYTHONPATH=. mypy --strict --exclude excluded_folder src
Success: no issues found in 2 source files
Expected Behavior
Mypy should also show the errors when the PYTHONPATH is set.
Actual Behavior
Mypy does not show the errors when the PYTHONPATH is set.
Your Environment
- Mypy version used:
mypy 1.8.0 (compiled: yes) - Mypy command-line flags: see commands above
- Mypy configuration options from
mypy.ini(and other config files): none - Python version used: Python 3.11.3
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- 平均マージ
- 1日 18時間
- マージ済み PR(30日)
- 54
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python/mypy のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
bug topic-configuration topic-error-reporting
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
似ている issue
-
area/auth bug comp/agent P3 platform/discord type/security
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
NousResearch/hermes-agent#117848 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
bancolombia/sentinel#23 ·
-
test md オープンCI
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
langchain-ai/deepagents#6450 ·
-
bug client
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100