New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow setting parameters with no defaults #588
Conversation
Current coverage is
|
@johtso, thank you for your pull request. 🍪 😎 Could you add a test for the condition? While this is technically covered by tests (https://codecov.io/github/audreyr/cookiecutter/cookiecutter/prompt.py?ref=bc3cb0ed034bde485d963ee9b50217cbd29ee069), that you added code that's a false positive. |
@pydanny will do! |
Hi @johtso! 👋 Could you please explain why you would have a variable with a default that is |
raw_var = str(raw_var) | ||
from_string.assert_called_once_with(raw_var) | ||
# Make sure that non None non str variables are conerted beforehand | ||
if raw_var is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This counteracts the extra test parameter! 😟
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, because the assertion doesn't apply anymore (there's still the assertion above checking the return value).
I could assert that it's not called I suppose..
This test does feel like it's basically replicating the same logic as the function it's testing.. but that's probably hard to avoid with such small functions.
@hackebrot the idea was that sometimes there is no sensible default for a value and you want to require that the user supplies one. Even if that's not a particularly useful use-case, it's definitely less surprising than converting |
Hey @johtso can you please rebase this guy? We sorted out the issues with AppVeyor and I'd like to see the test results for windows. Thank you 🙇 |
@hackebrot done 😸 |
if not isinstance(raw_var, basestring): | ||
raw_var = str(raw_var) | ||
from_string.assert_called_once_with(raw_var) | ||
# Make sure that non None non str variables are conerted beforehand |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sentence seems wrong 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any suggestions welcome! Looks like I kept a typo too..
Allow setting parameters with no defaults
Grats on your first pull request here @johtso. Welcome aboard! 🚢 🚋 |
Cheers @pydanny |
Fixes #587