summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2019-04-01 20:52:11 +0200
committerFlorian Bruhin <me@the-compiler.org>2019-04-29 15:57:37 +0200
commit2afb3929e91e87569cfae6db410da66276b7f581 (patch)
tree38a880a528a96aac5d431f1bded6b3f3919344f8
parent8f8d1ff3cd7aae8c7bb855218c62f35016521c1e (diff)
downloadqutebrowser-2afb3929e91e87569cfae6db410da66276b7f581.tar.gz
qutebrowser-2afb3929e91e87569cfae6db410da66276b7f581.zip
Remove TimestampTemplate configtype
The check being done only catches lone % signs, and only on some versions of Python: https://bugs.python.org/issue35066 Since we do the real formatting in sqlite anyways, just drop it, as we can't realistically validate it. Fixes #4693
-rw-r--r--doc/help/settings.asciidoc6
-rw-r--r--qutebrowser/config/configdata.yml7
-rw-r--r--qutebrowser/config/configtypes.py25
-rw-r--r--tests/unit/config/test_configtypes.py15
4 files changed, 7 insertions, 46 deletions
diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc
index 266a5d2d0..3d2c4d0b6 100644
--- a/doc/help/settings.asciidoc
+++ b/doc/help/settings.asciidoc
@@ -1475,8 +1475,9 @@ Default: +pass:[false]+
[[completion.timestamp_format]]
=== completion.timestamp_format
Format of timestamps (e.g. for the history completion).
+See https://sqlite.org/lang_datefunc.html for allowed substitutions.
-Type: <<types,TimestampTemplate>>
+Type: <<types,String>>
Default: +pass:[%Y-%m-%d]+
@@ -3680,9 +3681,6 @@ See the documentation for `List`.
See the setting's valid values for more information on allowed values.
|TextAlignment|Alignment of text.
-|TimestampTemplate|An strftime-like template for timestamps.
-
-See https://sqlite.org/lang_datefunc.html for reference.
|UniqueCharString|A string which may not contain duplicate chars.
|Url|A URL as a string.
|UrlPattern|A match pattern for a URL.
diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml
index e2d443280..07c196d52 100644
--- a/qutebrowser/config/configdata.yml
+++ b/qutebrowser/config/configdata.yml
@@ -858,10 +858,13 @@ completion.scrollbar.padding:
completion.timestamp_format:
type:
- name: TimestampTemplate
+ name: String
none_ok: true
default: '%Y-%m-%d'
- desc: Format of timestamps (e.g. for the history completion).
+ desc: >-
+ Format of timestamps (e.g. for the history completion).
+
+ See https://sqlite.org/lang_datefunc.html for allowed substitutions.
completion.web_history.exclude:
type:
diff --git a/qutebrowser/config/configtypes.py b/qutebrowser/config/configtypes.py
index 7b5125b1c..2c11251d3 100644
--- a/qutebrowser/config/configtypes.py
+++ b/qutebrowser/config/configtypes.py
@@ -1823,31 +1823,6 @@ class NewTabPosition(String):
('last', "At the end."))
-class TimestampTemplate(BaseType):
-
- """An strftime-like template for timestamps.
-
- See https://sqlite.org/lang_datefunc.html for reference.
- """
-
- def to_py(self, value: _StrUnset) -> _StrUnsetNone:
- self._basic_py_validation(value, str)
- if isinstance(value, configutils.Unset):
- return value
- elif not value:
- return None
-
- try:
- # Dummy check to see if the template is valid
- datetime.datetime.now().strftime(value)
- except ValueError as error:
- # thrown on invalid template string
- raise configexc.ValidationError(
- value, "Invalid format string: {}".format(error))
-
- return value
-
-
class Key(BaseType):
"""A name of a key."""
diff --git a/tests/unit/config/test_configtypes.py b/tests/unit/config/test_configtypes.py
index 7d7021770..e1cefec05 100644
--- a/tests/unit/config/test_configtypes.py
+++ b/tests/unit/config/test_configtypes.py
@@ -2086,21 +2086,6 @@ class TestConfirmQuit:
klass().to_py(val)
-class TestTimestampTemplate:
-
- @pytest.fixture
- def klass(self):
- return configtypes.TimestampTemplate
-
- @pytest.mark.parametrize('val', ['foobar', '%H:%M', 'foo %H bar %M'])
- def test_to_py_valid(self, klass, val):
- assert klass().to_py(val) == val
-
- def test_to_py_invalid(self, klass):
- with pytest.raises(configexc.ValidationError):
- klass().to_py('%')
-
-
class TestKey:
@pytest.fixture