python / python/mypy

Per-module options patterns starting with *

オープン
#8,522 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug priority-2-low topic-configuration
主要言語
Python
スター
20.6k
フォーク
3.3k
PR マージ指標
PR 指標を取得中

説明

Hi,
I am experimenting with per-module options and came across weird behavior when module patterns start with star. Documentation does not explicitly say if this is allowed or not, but I would assume it would work the same way as if it was "in the middle" of pattern. And IMHO there is no reason not to support it.

First issue:

From documentation:

Stars match zero or more module components

This is not the case for stars at the start of the string. For example [mypy-*.foo.bar] does not match module foo.bar

>>> import re
>>> from mypy.options import Options
>>> pattern = Options().compile_glob("*.foo.bar")
re.compile('.*\\.foo\\.bar\\Z')
>>> bool(re.match(pattern, "foo.bar"))
False

Second issue:

[mypy-*] does not match anything. I know that it does not make sense to use this since it is the same as global config, but it would be nice to work nonetheless.

In this case it is a bit more difficult: compile_glob returns correct re.compile('.*\\Z'), but there is some flawed logic in build_per_module_cache(), where it gets to concrete section since it does not end with ".*"


Python: 3.7.2
Mypy: 0.770

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

mypy/options.py の Options.compile_glob() と build_per_module_cache() から始め、次に issue の *.foo.bar と *. に関する 2 つの例を再現します。パターンがどのように分類されるかを確認し、先頭にアスタリスクがあるパターンが、アスタリスクは 0 個以上のモジュールコンポーネントにマッチするというドキュメント化されたルールに沿って一貫して動作することを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
devtools
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。