Cannot suppress python_version-related errors in third-party code
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Bug Report
If i have python_version = 3.5 set, it's not possible to tell mypy to ignore related syntax errors it finds in dependencies.
Use case: i have code which needs to support python 3.5, as well as newer versions. I run mypy against it under various versions of python, with python_version = 3.5 set so that i don't accidentally introduce something which is incompatible (like variable annotations) which might not get caught until later. This has worked fine until some of the dependencies have started using variable annotations.
To Reproduce
- Create a venv using python 3.6+.
pip install mypy importlib-metadata# Using importlib-metadata as an example lib which uses variable annotations- Create
setup.cfgwith:
[mypy]
python_version = 3.5
[mypy-importlib_metadata]
ignore_errors = True
- Create
test.pywith:
import importlib_metadata
- Run
mypy test.py
Expected Behavior
mypy should enforce python_version = 3.5 for test.py, but it should ignore any version-related issues in importlib_metadata.
Actual Behavior
mypy fails with:
venv/lib/python3.8/site-packages/importlib_metadata/__init__.py:88: error: Variable annotation syntax is only supported in Python 3.6 and greater
Found 1 error in 1 file (errors prevented further checking)
mypy doesn't seem to treat this as a 'fatal' error, either, as setting pdb = True has no effect.
Your Environment
- mypy 0.790 and 0.800
- python 3.6.7, 3.6.12 and 3.8.5
- Debian Stretch and Linux Mint 20.1 (Equivalent to Ubuntu 20.04)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、python_version = 3.5、importlib_metadata 依存関係、test.py、mypy test.py を含む setup.cfg 設定を再現します。import された依存関係から生じるバージョン関連の構文エラーを mypy がどのように処理するかを追跡します。完了条件は、test.py が引き続き Python 3.5 を強制し、依存関係のバージョン関連エラーが ignore_errors によって抑制されることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 35/100