python / python/mypy

Tracking variable whereabouts in a plugin

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

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

question topic-plugins
主要言語
Python
スター
20.6k
フォーク
3.3k
PR マージ指標
PR 指標を取得中

説明

Please provide more information to help us understand the issue:

  • Type: question
  • Referecenes:
  • Expected behavior: being able to track down variable i.e. from a process it was initialized.
    Code below should illustrate an expected behavior.
  • Actual behavior: n/a
  • mypy version: >=0.770
from luguru import logger

LOG_A = logger.opt(lazy=False)
LOG_B = logger.opt(lazy=True)

LOG_A.info('Test {}', lambda x: x)    # should work
LOG_B.info('Test {}', lambda x: x)    # error

logger.opt(lazy=False).info('Test {c}', c=lambda x: x)  # should work
logger.opt(lazy=True).info('Test {d}', d=lambda x: x)   # error

In short: with loguru you can use Callable[[], Any] for lazy loggers to avoid costly computations. But those have to be non-argument callables. Above you can find non-lazy loggers that will work just fine by doing str(callable). In other words, to rephrase question from above, how can we:

track a variable/object on which behalf a method was called?

This is quite vital because type checking cannot be done solely on a method call level because we need something from another call. There is opt method being called but having call details from it without anything to tie them to will not help too much.

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

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

はじめの一歩

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

調査の方向性

まず、リンク先の loguru-mypy の質問と loguru の元の pull request を確認し、その後、ここに示されている連鎖した opt(...).info(...) 呼び出しを mypy がどのように処理するかを調べます。この issue ではファイル、テスト、または確定した実装方針が特定されていません。完了するには、これらの呼び出し全体で logger オブジェクトを追跡するための合意された方法と、明確に定義された検証ケースが必要です。

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

評価

技術スタック
python
領域
tooling
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
20/100

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

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