Giter Club home page Giter Club logo

Comments (5)

pykong avatar pykong commented on August 24, 2024

@jpscaletti Can you see this issue I described and would be open to a PR which will give us a simpler more robust code? (Still passing all tests of course ;-) )

from copier.

pykong avatar pykong commented on August 24, 2024

Memo:

I really like how pydantic offers both validation and providing default values at the same time.
We could use this to first merge args provided by command line, configuration files and potentially environment variables and then validate against a defined scheme which will at the same time fill out all None values with defaults. Very powerful. Very elegant.

https://github.com/samuelcolvin/pydantic#a-simple-example

This is all done using the modern type hint syntax. Unfortunately, this means we will not be able to use pydantic for copier as we still support py 3.5.

from copier.

 avatar commented on August 24, 2024

I agree, this definetely could improve. As you said, here is too much code duplication.

About pydantic and validation, I don't think it is generally applicable enough to justify it.

from copier.

pykong avatar pykong commented on August 24, 2024

I agree, this definetely could improve. As you said, here is too much code duplication.

Great. I am working on a PR right now.

About pydantic and validation, I don't think it is generally applicable enough to justify it.

I am referring to our own variables, not any arbitrary setting a user might define.
For example we might check that extra_paths is actually a list of (valid) paths and quiet is a bool.
I consider it best practice to validate user input at a single place before feeding it into the deeper strata of a program. (It makes error handling easier and allows for easier way to provide feedback to the user.

As we are stuck with python 3.5 I need to find an alternative lib to pydantic or implement an own validation routine.

Do you concur that we should perform a basic validation of the user input at least?

from copier.

 avatar commented on August 24, 2024

from copier.

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.