Add convenience / utility methods to urllib.parse's structured result objects

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

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

評価

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

調査の方向性

まず urllib.parse の構造化された結果オブジェクトと既存の mixin を確認し、次に比較のためリンクされている werkzeug.urls のユーティリティを確認します。提案するヘルパーのセットとその動作が、query の更新および選択した URL または userinfo ヘルパーを含め、合意した範囲に絞り込まれれば完了です。

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

説明

stdlib type-feature

Currently, non-trivial URL manipulations require going back and forth between structured results and utility functions in order to process or manipulate the URL in non-trivial ways (other than entirely replacing one of the attributes).

werkzeug.urls (which started as a cross-version compatibility shim) shows a few utility properties and methods:

  • join, which performs a Resutl -> Result urljoin
  • decode_query, which performs a parse_qs (-l, kind-of, as werkzeug uses multidicts)
  • ascii_host, which return a punycode/idna-encoded domain if necessary
  • auth, which returns the encoded userinfo

The first three are commonly useful, and require a fair amount of syntactic overhead to perform using the stdlib. The 4th would mostly be solved by making _userinfo public / stable and documenting it, though a purely textual version could also be useful.

One utility which I think is missing from werkzeug and would also be useful is a shortcut to set/update query string parameters directly, which IME is quite common: looking at a pretty url-heavy codebase, 20~30% of the querystring manipulations are straighforward set-and-forget (the rest is lookups, with a few odd more complicated manipulations of the query string which do need to fully decode and process the result).

As urllib.parse already layers a few mixins on top of the base namedtuples, I don't think this would incur significant runtime costs (the helpers could probably be added to existing mixins)

主要言語
Python
スター
77.2k
フォーク
36k
平均マージ
1日 9時間
マージ済み PR(30日)
558

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

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

はじめの一歩

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

python/cpython のほかの issue

python/cpython の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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