Allow for subclassed types

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

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

評価

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

調査の方向性

まず、jmespath.functions.REVERSE_TYPES_MAP の周辺の処理と、contains() で使用されている型検証を調べます。リンクされている Ansible issue を確認してサブクラス化された文字列の挙動を把握し、直接的な map の変更をサポートされた拡張ポイントで置き換えられるか判断します。サブクラス化された string 型が、プライベートに見える内部構造に依存せず受け入れられ、報告されたケースの回帰テストカバレッジが追加されていれば完了です。

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

説明

A little background first, in Ansible there is a json_query filter plugin which uses jmespath to query json. There is an issue open where users of that plugin get the following error:

JMESPathTypeError: In function contains(), invalid type for value: irb.1111, expected one of: ['array', 'string'], received: "unknown"

The comment that summarizes the issue is here https://github.com/ansible/ansible/issues/27299#issuecomment-366781707.

The error is caused by the fact that Ansible uses its own types for strings. One of the hacks we've come up with was:

jmespath.functions.REVERSE_TYPES_MAP['string'] = jmespath.functions.REVERSE_TYPES_MAP['string'] + ('AnsibleUnicode', 'AnsibleUnsafeText',)

which seems weird since I am pretty sure REVERSE_TYPES_MAP is not supposed to be public.

is there a proper way to do this? If not, is this something that would be considered to be added?

Thanks!

主要言語
Python
スター
2.5k
フォーク
231
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

jmespath/jmespath.py のほかの issue

jmespath/jmespath.py の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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