2828
2929# 3rd party
3030from configconfig .configvar import ConfigVar
31+ from configconfig .utils import RawConfigVarsType
32+ from natsort import natsorted
3133
32- __all__ = ["python_deploy_version" , "default_python_versions" , "python_versions" , "third_party_version_matrix" ]
34+ __all__ = [
35+ "python_deploy_version" ,
36+ "requires_python" ,
37+ "default_python_versions" ,
38+ "python_versions" ,
39+ "third_party_version_matrix"
40+ ]
3341
3442
3543class python_deploy_version (ConfigVar ): # noqa
@@ -49,6 +57,32 @@ class python_deploy_version(ConfigVar): # noqa
4957 category : str = "python versions"
5058
5159
60+ class requires_python (ConfigVar ): # noqa
61+ """
62+ The minimum required version of Python.
63+
64+ Example:
65+
66+ .. code-block:: yaml
67+
68+ requires_python: 3.6.1
69+
70+ .. versionadded:: $VERSION
71+ """
72+
73+ dtype = Union [str , float ]
74+ rtype = str
75+ default = None
76+ category : str = "python versions"
77+
78+ @classmethod
79+ def validate (cls , raw_config_vars : Optional [RawConfigVarsType ] = None ) -> Any :
80+ if cls .__name__ in raw_config_vars :
81+ return super ().validate (raw_config_vars )
82+ else :
83+ return None
84+
85+
5286def default_python_versions (raw_config_vars : Optional [Dict [str , Any ]]) -> List [str ]:
5387 """
5488 Function to return the default value for :conf:`python_versions`.
@@ -81,7 +115,7 @@ class python_versions(ConfigVar): # noqa
81115
82116 @classmethod
83117 def validator (cls , value : Iterable [str ]) -> List [str ]: # noqa: D102
84- return [ str (ver ) for ver in value if ver ]
118+ return natsorted ( str (ver ) for ver in value if ver )
85119
86120
87121class third_party_version_matrix (ConfigVar ): # noqa
0 commit comments