Comments (5)
@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.
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.
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.
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.
from copier.
Related Issues (20)
- Updating the project creates a new .copier-answer.yml file HOT 3
- Allow templating items in `_exclude` HOT 17
- Provide a way to integrate with nix templates HOT 1
- Error when running `poe lint` with Podman HOT 1
- Use pyclean instead of custom code, maybe?
- Unable to set default value on a choice answer HOT 3
- Cli Support for _envops and _subdirectory HOT 5
- Copier fails if git is not installed
- Nested Questions Asked Incorrectly HOT 2
- Validators don't work when answers passed with --data flag HOT 3
- Enhance Multiselect Questions with Choice Dependencies HOT 2
- Current working directory during `copier {copy,recopy,update}` should be destination path
- Template update process on Copier 9.3.0/9.3.1 is slow/indefinite on Windows compared with 9.2.0 for repos with lots of `.gitignore`s (I suspect a new `copytree` operation) HOT 3
- missing config when using git clone HOT 2
- `skip_if_exists` interaction with deleted files on update HOT 7
- Inconsistent `update` behavior when a generated file was deleted HOT 5
- Exclude on update HOT 10
- Conditional argument ignored when updating HOT 4
- Bool argument is handled as string in 'recopy' operation HOT 3
- Allow source argument for update HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from copier.