Allow formats for non-string types
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 38/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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?
- Vorherrschende Sprache
- Python
- Sterne
- 281
- Forks
- 35
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus python-jsonschema/hypothesis-jsonschema
-
Missing test files in Pypi releaseEvtl. vergeben @blouirts123 hat das vor 49 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 35/100
-
Shouldn't PKG-INFO Homepage point to https://github.com/python-jsonschema/hypothesis-jsonschema ?Offen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 58/100
python-jsonschema/hypothesis-jsonschema#114 · 1 Kommentar ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 55/100
python-jsonschema/hypothesis-jsonschema#113 · 1 Reaktion ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 30/100
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 15/100
python-jsonschema/hypothesis-jsonschema#104 · 3 Reaktionen ·
Alle Issues in python-jsonschema/hypothesis-jsonschema
Ähnliche Issues
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100
Techiebutler/freeframe#687 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug verbose GC
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
IBM/javacore-analyser#677 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 79/100
Maintainer antworten meist innerhalb von 2 Tagen
-
area/config comp/plugins P1 platform/qqbot tool/file type/bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
NousResearch/hermes-agent#163932 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
plugins/dsh: todayStr() computes UTC but is documented as local — journal entries written 00:00–08:00 local land in the previous day's fileEvtl. vergeben @Beehtrix hat das heute übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
zilliztech/memsearch#907 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag