Skip to content

Commit 46c2ffb

Browse files
committed
Refactoring and docstrings
1 parent 058fadd commit 46c2ffb

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

readthedocs/config/config.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494

9595

9696
def _list_to_dict(list_):
97+
"""Transform a list to a dictionary with its indices as keys."""
9798
dict_ = {
9899
str(i): element
99100
for i, element in enumerate(list_)
@@ -572,6 +573,9 @@ def python(self):
572573
python = self._config['python']
573574
requirements = self._config['requirements_file']
574575
python_install = []
576+
577+
# Alwyas append a `PythonInstallRequirements` option.
578+
# If requirements is None, rtd will try to find a requirements file.
575579
python_install.append(
576580
PythonInstallRequirements(
577581
requirements=requirements,
@@ -777,6 +781,7 @@ def validate_python(self):
777781
raw_install = self.raw_config.get('python', {}).get('install', [])
778782
validate_list(raw_install)
779783
if raw_install:
784+
# Transform to a dict, so it's easy to validate extra keys.
780785
self.raw_config.setdefault('python', {})['install'] = (
781786
_list_to_dict(raw_install)
782787
)
@@ -803,7 +808,7 @@ def validate_python(self):
803808
return python
804809

805810
def validate_python_install(self, index):
806-
"""Validates the python.install.index key."""
811+
"""Validates the python.install.{index} key."""
807812
python_install = {}
808813
key = 'python.install.{}'.format(index)
809814
raw_install = self.raw_config['python']['install'][str(index)]
@@ -835,14 +840,14 @@ def validate_python_install(self, index):
835840
)
836841
python_install['method'] = method
837842

838-
extrareq_key = key + '.extra_requirements'
839-
with self.catch_validation_error(extrareq_key):
843+
extra_req_key = key + '.extra_requirements'
844+
with self.catch_validation_error(extra_req_key):
840845
extra_requirements = validate_list(
841-
self.pop_config(extrareq_key, [])
846+
self.pop_config(extra_req_key, [])
842847
)
843848
if extra_requirements and python_install['method'] != PIP:
844849
self.error(
845-
extrareq_key,
850+
extra_req_key,
846851
'You need to install your project with pip '
847852
'to use extra_requirements',
848853
code=PYTHON_INVALID,

0 commit comments

Comments
 (0)