python / python/mypy

local / in-folder setup.cfg without mypy section shadows any additional user config files

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

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

feature topic-configuration
主要言語
Python
スター
20.6k
フォーク
3.3k
平均マージ
1日 18時間
マージ済み PR(30日)
54

説明

As the config file read order defined by the order of the lists at https://github.com/python/mypy/blob/master/mypy/defaults.py#L15
is

CONFIG_FILES = CONFIG_FILE + SHARED_CONFIG_FILES + USER_CONFIG_FILES  # type: Final

a shared config file (which may exist for several other purposes) shadows any user config files even in the case when
the shared config file contains no mypy section.

Steps to reproduce:

  • Create an empty setup.cfg in the current directory, and also have one of the USER_CONFIG_FILE versions of a mypy config file.
  • Run mypy
  • Notice that only the setup.cfg file was read, even though it had no mypy section.
    `

Proposal

The logic which checks for a mypy section in the parser object (https://github.com/python/mypy/blob/master/mypy/config_parser.py#L127) should be used to check whether the parser.read call actually loaded anything meaningful from the config file. If no mypy section was loaded, then the loop over the config_files should continue instead of breaking.

This should at least be the case for any shared config files which may exist for entirely other reasons.

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

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

はじめの一歩

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

調査の方向性

mypy/defaults.py の CONFIG_FILES の順序と、mypy/config_parser.py の parser セクションのチェックから始めます。空の setup.cfg とユーザー設定ファイルを使って問題を再現し、共有ファイルに mypy セクションがない場合でも設定の読み込みが継続し、ユーザー設定が反映されることを確認します。

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

評価

技術スタック
python
領域
developer-experience, tooling
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
55/100

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

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