aio-libs / aio-libs/yarl

Support building query without values

オープン
#307 コメント 5 件 リアクション 2 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
1.5k
フォーク
215
平均マージ
1日 2分
マージ済み PR(30日)
13

説明

Sometimes query consists not only of pairs of keys and values but also can contain standalone keys. In my opinion, it's bad, but I encountered this a few times in different APIs.
For example, I need to build a URL like: https://api.crowdin.com/api/project/{project_identifier}/pre-translate?key={project_key}&json (see https://support.crowdin.com/api/pre-translate/ for details).

I propose to make an interface look like this:
```python
url = URL('https://api.crowdin.com/api/project/{project-identifier}/pre-translate')
url = url.with_query(key=project_key, json=None)
```
This is safe because now passing `None` as keyword argument value raises `TypeError`. If user wants to get an URL with `json=` (note that the last symbol is the equals sign), he passes `json=''` as he does now.

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

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

評価

この issue はまだ評価されていません。

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

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