94
94
95
95
96
96
def _list_to_dict (list_ ):
97
+ """Transform a list to a dictionary with its indices as keys."""
97
98
dict_ = {
98
99
str (i ): element
99
100
for i , element in enumerate (list_ )
@@ -572,6 +573,9 @@ def python(self):
572
573
python = self ._config ['python' ]
573
574
requirements = self ._config ['requirements_file' ]
574
575
python_install = []
576
+
577
+ # Alwyas append a `PythonInstallRequirements` option.
578
+ # If requirements is None, rtd will try to find a requirements file.
575
579
python_install .append (
576
580
PythonInstallRequirements (
577
581
requirements = requirements ,
@@ -777,6 +781,7 @@ def validate_python(self):
777
781
raw_install = self .raw_config .get ('python' , {}).get ('install' , [])
778
782
validate_list (raw_install )
779
783
if raw_install :
784
+ # Transform to a dict, so it's easy to validate extra keys.
780
785
self .raw_config .setdefault ('python' , {})['install' ] = (
781
786
_list_to_dict (raw_install )
782
787
)
@@ -803,7 +808,7 @@ def validate_python(self):
803
808
return python
804
809
805
810
def validate_python_install (self , index ):
806
- """Validates the python.install.index key."""
811
+ """Validates the python.install.{ index} key."""
807
812
python_install = {}
808
813
key = 'python.install.{}' .format (index )
809
814
raw_install = self .raw_config ['python' ]['install' ][str (index )]
@@ -835,14 +840,14 @@ def validate_python_install(self, index):
835
840
)
836
841
python_install ['method' ] = method
837
842
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 ):
840
845
extra_requirements = validate_list (
841
- self .pop_config (extrareq_key , [])
846
+ self .pop_config (extra_req_key , [])
842
847
)
843
848
if extra_requirements and python_install ['method' ] != PIP :
844
849
self .error (
845
- extrareq_key ,
850
+ extra_req_key ,
846
851
'You need to install your project with pip '
847
852
'to use extra_requirements' ,
848
853
code = PYTHON_INVALID ,
0 commit comments