GithubHelp home page GithubHelp logo

Comments (5)

Stranger6667 avatar Stranger6667 commented on August 24, 2024 1

Update. I had a slight problem in my code - now there are no perf regressions :) Will push the new version soon

from hypothesis-jsonschema.

Zac-HD avatar Zac-HD commented on August 24, 2024

Huh, I'm surprised this didn't come up earlier. Rather than threading the validator we need through everywhere, how about we rip off this trick:

https://github.com/Zac-HD/hypothesis-jsonschema/blob/c1a12bb034679751a802bbb03efcbcab00d09e18/tests/test_from_schema.py#L268-L271

and just define a get_validator_for(schema) function which tries the upstream get_validator, and falls back to the Draft4Validator if .check_schema() raises? This is might be conceptually pretty dodgy, but the code will look a lot nicer!

from hypothesis-jsonschema.

Stranger6667 avatar Stranger6667 commented on August 24, 2024

It seems like a feasible approach, at least short-term. But I am concerned that it might cause potential problems in the future - for example, when Draft 2019-09 will be more common, and it will be the default validator, then it might be ambiguous what fallback should be used. Luckily, there are no backward-incompatible changes between Draft 6 & 7, so using Draft 4 should be ok.

Another thing is that for recursive schemas, there could be some more pieces to pass along - e.g., ref resolver. I was wondering if it might make sense to create a "context" object that could contain everything needed instead of passing dependencies as separate arguments. In this case, there could be a resolver and a validator, and extending it might be easier than adding new args across the codebase.

However, I feel perfectly fine with fallback to Draft 4 now - it still can be redesigned later if needed.

from hypothesis-jsonschema.

Zac-HD avatar Zac-HD commented on August 24, 2024

From memory all draft7 schemas are also valid in draft 2019-09, so let's stick with the simple solution for now. As you say, we can always change it over later if it stops working!

from hypothesis-jsonschema.

Stranger6667 avatar Stranger6667 commented on August 24, 2024

I found another small issue - the test suite run becomes consistently ~25% slower :( I will push the new version in a separate commit - maybe there is something with the implementation itself

from hypothesis-jsonschema.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.