Use null for empty config values.

This commit is contained in:
Florian Bruhin 2017-06-13 13:51:05 +02:00
parent af134eb861
commit 231b7303f5
2 changed files with 19 additions and 15 deletions

View File

@ -34,10 +34,10 @@ downloads.open_dispatcher:
type: type:
name: String name: String
none_ok: true none_ok: true
default: "" default: null
desc: >- desc: >-
The default program used to open downloads. Set to an empty string to use The default program used to open downloads. If unset, the default internal
the default internal handler. handler is used.
Any `{}` in the string will be expanded to the filename, else the filename Any `{}` in the string will be expanded to the filename, else the filename
will be appended. will be appended.
@ -184,8 +184,8 @@ session_default_name:
type: type:
name: SessionName name: SessionName
none_ok: true none_ok: true
default: "" default: null
desc: The name of the session to save by default, or empty for the last loaded desc: The name of the session to save by default, or unset for the last loaded
session. session.
url_incdec_segments: url_incdec_segments:
@ -285,7 +285,7 @@ content.user_stylesheet:
type: type:
name: File name: File
none_ok: True none_ok: True
default: "" default: null
desc: User stylesheet to use (absolute filename or filename relative to the config desc: User stylesheet to use (absolute filename or filename relative to the config
directory). Will expand environment variables. directory). Will expand environment variables.
@ -367,7 +367,7 @@ keyhint.blacklist:
valtype: valtype:
name: String name: String
none_ok: true none_ok: true
default: "" default: null
desc: >- desc: >-
Keychains that shouldn\'t be shown in the keyhint dialog. Keychains that shouldn\'t be shown in the keyhint dialog.
@ -419,7 +419,7 @@ content.referer_header:
desc: Send the Referer header desc: Send the Referer header
content.user_agent: content.user_agent:
default: "" default: null
type: type:
name: String name: String
none_ok: true none_ok: true
@ -467,7 +467,7 @@ content.user_agent:
- - "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko" - - "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
- IE 11.0 for Desktop Win7 64-bit - IE 11.0 for Desktop Win7 64-bit
desc: User agent to send. Empty to send the default. desc: User agent to send. Unset to send the default.
content.proxy: content.proxy:
default: system default: system
@ -516,11 +516,11 @@ content.custom_headers:
desc: Set custom headers for qutebrowser HTTP requests. desc: Set custom headers for qutebrowser HTTP requests.
content.netrc_file: content.netrc_file:
default: "" default: null
type: type:
name: File name: File
none_ok: true none_ok: true
desc: Set location of a netrc-file for HTTP authentication. If empty, ~/.netrc desc: Set location of a netrc-file for HTTP authentication. If unset, ~/.netrc
is used. is used.
@ -889,12 +889,12 @@ tabs.indicator_padding:
# storage # storage
downloads.location.directory: downloads.location.directory:
default: "" default: null
type: type:
name: Directory name: Directory
none_ok: true none_ok: true
desc: The directory to save downloads to. An empty value selects a sensible os-specific desc: The directory to save downloads to. If unset, a sensible os-specific
default. Will expand environment variables. default is used. Will expand environment variables.
downloads.location.prompt: downloads.location.prompt:
default: true default: true

View File

@ -116,7 +116,11 @@ class BaseType:
value: The value to check. value: The value to check.
pytype: If given, a Python type to check the value against. pytype: If given, a Python type to check the value against.
""" """
if pytype is not None and not isinstance(value, pytype): if value is None and not self.none_ok:
raise configexc.ValidationError(value, "may not be empty!")
if (value is not None and pytype is not None and
not isinstance(value, pytype)):
raise configexc.ValidationError( raise configexc.ValidationError(
value, "expected a value of type {} but got {}".format( value, "expected a value of type {} but got {}".format(
pytype, type(value))) pytype, type(value)))