Skip to content
Myr

Pass default values through the type system.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 9c8a3eb · Browse files · 1 file+6 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+6 added−2 removed

  • other:+6 added−2 removed

1 file+6 added−2 removed

modified:click.py+6 added-2 removed
802 unmodified lines
803 self.errors = errors804805 def convert(self, value, param, ctx):806 try:807 if hasattr(value, 'read') or hasattr(value, 'write'):808 return value809 f, was_opened = open_stream(value, self.mode, self.encoding,810 self.errors)811 # If a context is provided we automatically close the file812 # at the end of the context execution (or flush out). If a
104 unmodified lines
917 def get_default(self, ctx):918 """Given a context variable this calculates the default value."""919 # Otherwise go with the regular default.920 if callable(self.default):919 return self.default()920 return self.default921 rv = self.default()922 else:923 rv = self.default924 return self.type(rv, self, ctx)925926 def _add_to_parser(self, parser, ctx):927 raise NotImplementedError()928
609 unmodified lines