Allow formats for non-string types
还没有人认领这个 Issue。
评估
调研方向
Start with the restriction in src/hypothesis_jsonschema/_from_schema.py around line 104, which the issue identifies as raising when a generated value is not a string. Read the format checker handling and its tests to see how format validation currently treats instance types. Done means non-string instances can use format checkers without raising, with tests covering the supported cases.
由索引模型根据 Issue 内容生成。
描述
As per Draft 4 and Draft 7 validation docs:
A format attribute can generally only validate a given set of instance types. If the type of the instance to validate is not in this set, validation for this format attribute and instance SHOULD succeed.
Newer drafts are more clear on this matter. For example, Draft 2020-12 additionally provides this:
All format attributes defined in this section apply to strings, but a format attribute can be specified to apply to any instance types defined in the data model defined in the core JSON Schema.
Even though, that the supported drafts (4, 6, 7) are a bit vague about instance types, I think that it could be treated as they allow non-string instances. The Open API spec explicitly uses it with int32, float, and other formats that are applicable for non-string types.
jsonschema also supports arbitrary types for its format checkers, at least based on its docstring:
Check whether the instance conforms to the given format.
Arguments:
instance (*any primitive type*, i.e. str, number, bool):
The instance to check
Currently, hypothesis-jsonschema raises an error if a strategy produces a non-string value.
What do you think about removing this restriction?
- 主要语言
- Python
- 星标
- 281
- 派生
- 35
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
python-jsonschema/hypothesis-jsonschema 的其他 Issue
-
Missing test files in Pypi release可能已有人在做 @blouirts123 于 49 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 35/100
-
Shouldn't PKG-INFO Homepage point to https://github.com/python-jsonschema/hypothesis-jsonschema ?未关闭
难度 1/5 1 小时以内 新手友好度 58/100
python-jsonschema/hypothesis-jsonschema#114 · 1 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 55/100
python-jsonschema/hypothesis-jsonschema#113 · 1 个 reaction ·
-
难度 5/5 一周以上 新手友好度 30/100
-
难度 5/5 一周以上 新手友好度 15/100
python-jsonschema/hypothesis-jsonschema#104 · 3 个 reaction ·
查看 python-jsonschema/hypothesis-jsonschema 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 92/100
Techiebutler/freeframe#687 ·
维护者通常 1 天内回复
-
bug verbose GC
难度 2/5 1-3 小时 新手友好度 74/100
IBM/javacore-analyser#677 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 79/100
维护者通常 2 天内回复
-
area/config comp/plugins P1 platform/qqbot tool/file type/bug
难度 2/5 1-3 小时 新手友好度 75/100
NousResearch/hermes-agent#163932 · 1 条评论 ·
维护者通常 1 天内回复
-
plugins/dsh: todayStr() computes UTC but is documented as local — journal entries written 00:00–08:00 local land in the previous day's file可能已有人在做 @Beehtrix 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 82/100
zilliztech/memsearch#907 · 1 条评论 ·
维护者通常 1 天内回复