allow variables named `_` (underscore) to be untyped (throwaway variables)
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Feature
There is a very common practice in python, to use the underscore character - _ - as a variable name for a "throwaway character" - mostly when receiving function output values that will not be used, or when implementing functions with defined signatures, without using some of the variables.
The feature request is to allow these variables to be without type hints, and do not warn.
Pitch
In our company, we work a lot with web development, APIs and such, and it is very common to have to implement predefined function signatures. For example, when using AWS lambdas, one needs to implement:
def lambda_handler(event, context):
However, it is very common to only use the event parameter in the code, and not the context - meaning many times we implement
def lambda_handler(event, _):
when typing the function, I currently do something like this
from typing import Any
def lambda_handler(event: dict, _: Any) -> None:
since I do not necessarily know what the _/context variable type is, and I do not care to invest work in finding it when the variable is not in use. It would be easier and nicer if I could simply do this
def lambda_handler(event: dict, _) -> None:
There are plenty of other examples, similar to this, and so I am sure this feature can be useful to many other people. I think even if the feature were to be configurable with a flag (allow_untyped_underscore or something) that would be very helpful as well.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
ファイル、テスト、エントリポイントのいずれも指定されていません。まず、型付けされていない関数パラメーターに対する mypy の処理と、underscore に関連する既存のチェックを調べてください。完了とは、underscore パラメーターが警告なしに型ヒントを省略でき、意図された動作と設定上の選択肢が明確になっていることを意味するものとします。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100