Some typos, documentation fixes and Python idioms

This commit is contained in:
Frank Sachsenheim
2017-09-18 09:39:01 +02:00
committed by Waylan Limberg
parent 34cb58c124
commit 2b0690d6df
2 changed files with 10 additions and 12 deletions

View File

@@ -25,10 +25,9 @@ class BaseConfigOption(object):
def pre_validation(self, config, key_name):
"""
After all options have passed validation, perform a post validation
process to do any additional changes dependant on other config values.
Before all options are validated, perform a pre-validation process.
The post validation process method should be implemented by subclasses.
The pre-validation process method should be implemented by subclasses.
"""
def run_validation(self, value):
@@ -41,10 +40,10 @@ class BaseConfigOption(object):
def post_validation(self, config, key_name):
"""
After all options have passed validation, perform a post validation
After all options have passed validation, perform a post-validation
process to do any additional changes dependant on other config values.
The post validation process method should be implemented by subclasses.
The post-validation process method should be implemented by subclasses.
"""
@@ -147,10 +146,10 @@ class Type(OptionallyRequired):
def run_validation(self, value):
if not isinstance(value, self._type):
msg = ("Expected type: {0} but recieved: {1}"
msg = ("Expected type: {0} but received: {1}"
.format(self._type, type(value)))
elif self.length is not None and len(value) != self.length:
msg = ("Expected type: {0} with lenght {2} but recieved: {1} with "
msg = ("Expected type: {0} with length {2} but received: {1} with "
"length {3}").format(self._type, value, self.length,
len(value))
else:
@@ -518,12 +517,11 @@ class Pages(Extras):
return
config_types = set(type(l) for l in value)
if config_types.issubset(set([utils.text_type, dict, str])):
if config_types.issubset({utils.text_type, dict, str}):
return value
raise ValidationError("Invalid pages config. {0} {1}".format(
config_types,
set([utils.text_type, dict, ])
config_types, {utils.text_type, dict}
))
def post_validation(self, config, key_name):

View File

@@ -1,13 +1,13 @@
# coding: utf-8
from __future__ import unicode_literals
from __future__ import absolute_import, unicode_literals
import os
import logging
from mkdocs import utils
from mkdocs.plugins import BasePlugin
from mkdocs.contrib.legacy_search.search_index import SearchIndex
from .search_index import SearchIndex
log = logging.getLogger(__name__)