Add single configuration option to retain various old behaviors
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Every once in a while we change something in mypy that breaks backward compatibility, and this can make it hard for owners of large codebases to migrate to a new mypy version. A related issue is that some changes that we'd like to make would cause so much work for existing users that we decide to postpone the change indefinitely (see #5392 as an example).
What if we'd adopt a policy of retaining the old behaviors through a configuration option, whenever there is a lot of expected breakage? This way existing users could just continue to use the old behavior without having to migrate their code, while new users would automatically get the new (and improved, I'd hope) behavior.
A potential drawback would be the introduction of many additional options for legacy behaviors that are only of interest to a small subset of users. My solution to this is to enable all of the behaviors with a single option.
Let's use #5392 as an example. The change would cause some if/else expression to return a union type instead of a join. We could enable the old behavior through --backward-compat if-else (the option name needs more thought). The value of the option would be a comma-separated list of legacy behaviors.
Another candidate for this feature is #5401.
Pros:
- Migration to new mypy versions will be easier for users with lots of code.
- Breaking changes are easier to justify, since we can provide a fallback for existing users.
- Backward compatibility features are behind a single option which can be easily ignored by users that don't care about it.
- If the compatibility options are per-module, migration to new semantics can be performed gradually.
Cons:
- Some users may be unaware of the option and be reluctant to upgrade to new mypy versions because of the migration work they believe to be necessary.
- Supporting multiple additional options may decrease maintainability of mypy and result in bugs and weird corner cases.
- We may never be able to deprecate some old behaviors.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず提案と関連する issue #5392 および #5401 を読みます。mypy が現在どのように設定オプションを扱っているか、また影響を受ける型チェックの動作を確認します。対象範囲とサポートするレガシー動作を含む、単一のカンマ区切りの互換性オプションについて合意された設計ができれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- compilers, devtools
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100