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
This commit is contained in:
Florian Bruhin 2019-04-01 20:52:11 +02:00
parent c62fea4c87
commit 828a393b20
4 changed files with 7 additions and 46 deletions

View File

@ -1548,8 +1548,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]+
@ -3753,9 +3754,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.

View File

@ -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:

View File

@ -1832,31 +1832,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."""

View File

@ -2084,21 +2084,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