@@ -77,10 +77,11 @@ def save_results(results, base):
77
77
78
78
def find_pylintrc_in (search_dir ):
79
79
"""Find a pylintrc file in the given directory.
80
+
80
81
:param search_dir: The directory to search.
81
82
:type search_dir: str
82
- :returns: The path to the pylintrc file, if found.
83
- Otherwise None.
83
+
84
+ :returns: The path to the pylintrc file, if found. Otherwise None.
84
85
:rtype: str or None
85
86
"""
86
87
path = None
@@ -96,8 +97,10 @@ def find_pylintrc_in(search_dir):
96
97
97
98
def find_nearby_pylintrc (search_dir = '' ):
98
99
"""Search for the nearest pylint rc file.
100
+
99
101
:param search_dir: The directory to search.
100
102
:type search_dir: str
103
+
101
104
:returns: The absolute path to the pylintrc file, if found.
102
105
Otherwise None
103
106
:rtype: str or None
@@ -121,8 +124,8 @@ def find_nearby_pylintrc(search_dir=''):
121
124
122
125
def find_global_pylintrc ():
123
126
"""Search for the global pylintrc file.
124
- :returns: The absolute path to the pylintrc file, if found.
125
- Otherwise None.
127
+
128
+ :returns: The absolute path to the pylintrc file, if found. Otherwise None.
126
129
:rtype: str or None
127
130
"""
128
131
pylintrc = None
@@ -149,8 +152,8 @@ def find_pylintrc():
149
152
- The current user's home directory
150
153
- The `.config` folder in the current user's home directory
151
154
- /etc/pylintrc
152
- :returns: The path to the pylintrc file,
153
- or None if one was not found.
155
+
156
+ :returns: The path to the pylintrc file, or None if one was not found.
154
157
:rtype: str or None
155
158
"""
156
159
# TODO: Find nearby pylintrc files as well
@@ -717,6 +720,7 @@ def __iadd__(self, other):
717
720
class ConfigurationStore (object ):
718
721
def __init__ (self , global_config ):
719
722
"""A class to store configuration objects for many paths.
723
+
720
724
:param global_config: The global configuration object.
721
725
:type global_config: Configuration
722
726
"""
@@ -727,6 +731,7 @@ def __init__(self, global_config):
727
731
728
732
def add_config_for (self , path , config ):
729
733
"""Add a configuration object to the store.
734
+
730
735
:param path: The path to add the config for.
731
736
:type path: str
732
737
:param config: The config object for the given path.
@@ -740,8 +745,10 @@ def add_config_for(self, path, config):
740
745
741
746
def _get_parent_configs (self , path ):
742
747
"""Get the config objects for all parent directories.
748
+
743
749
:param path: The absolute path to get the parent configs for.
744
750
:type path: str
751
+
745
752
:returns: The config objects for all parent directories.
746
753
:rtype: generator(Configuration)
747
754
"""
@@ -756,8 +763,10 @@ def get_config_for(self, path):
756
763
"""Get the configuration object for a file or directory.
757
764
This will merge the global config with all of the config objects from
758
765
the root directory to the given path.
766
+
759
767
:param path: The file or directory to the get configuration object for.
760
768
:type path: str
769
+
761
770
:returns: The configuration object for the given file or directory.
762
771
:rtype: Configuration
763
772
"""
@@ -811,9 +820,11 @@ def add_option_definition(self, option_definition):
811
820
@abc .abstractmethod
812
821
def parse (self , to_parse , config ):
813
822
"""Parse the given object into the config object.
814
- Args:
815
- to_parse (object): The object to parse.
816
- config (Configuration): The config object to parse into.
823
+
824
+ :param to_parse: The object to parse.
825
+ :type to_parse: object
826
+ :param config: The config object to parse into.
827
+ :type config: Configuration
817
828
"""
818
829
819
830
@@ -851,16 +862,16 @@ def add_option_definitions(self, option_definitions):
851
862
def _convert_definition (option , definition ):
852
863
"""Convert an option definition to a set of arguments for add_argument.
853
864
854
- Args:
855
- option (str): The name of the option
856
- definition (dict): The argument definition to convert.
865
+ :param option: The name of the option
866
+ :type option: str
867
+ :param definition: The argument definition to convert.
868
+ :type definition: dict
857
869
858
- Returns:
859
- tuple(str, list, dict): A tuple of the group to add the argument to,
870
+ :returns: A tuple of the group to add the argument to,
860
871
plus the args and kwargs for :func:`ArgumentParser.add_argument`.
872
+ :rtype: tuple(str, list, dict)
861
873
862
- Raises:
863
- Exception: When the definition is invalid.
874
+ :raises ConfigurationError: When the definition is invalid.
864
875
"""
865
876
args = []
866
877
@@ -897,20 +908,24 @@ def _convert_definition(option, definition):
897
908
898
909
def parse (self , argv , config ):
899
910
"""Parse the command line arguments into the given config object.
900
- Args:
901
- argv (list(str)): The command line arguments to parse.
902
- config (Configuration): The config object to parse
903
- the command line into.
911
+
912
+ :param argv: The command line arguments to parse.
913
+ :type argv: list(str)
914
+ :param config: The config object to parse the command line into.
915
+ :type config: Configuration
904
916
"""
905
917
self ._parser .parse_args (argv , config )
906
918
907
919
def preprocess (self , argv , * options ):
908
920
"""Do some guess work to get a value for the specified option.
909
- Args:
910
- argv (list(str)): The command line arguments to parse.
911
- *options (str): The names of the options to look for.
912
- Returns:
913
- Configuration: A config with the processed options.
921
+
922
+ :param argv: The command line arguments to parse.
923
+ :type argv: list(str)
924
+ :param options: The names of the options to look for.
925
+ :type options: str
926
+
927
+ :returns: A config with the processed options.
928
+ :rtype: Configuration
914
929
"""
915
930
config = Config ()
916
931
config .add_options (self ._option_definitions )
@@ -955,9 +970,13 @@ def add_option_definitions(self, option_definitions):
955
970
def _convert_definition (option , definition ):
956
971
"""Convert an option definition to a set of arguments for the parser.
957
972
958
- Args:
959
- option (str): The name of the option.
960
- definition (dict): The argument definition to convert.
973
+ :param option: The name of the option.
974
+ :type option: str
975
+ :param definition: The argument definition to convert.
976
+ :type definition: dict
977
+
978
+ :returns: The converted definition.
979
+ :rtype: tuple(str, dict)
961
980
"""
962
981
default = {option : definition .get ('default' )}
963
982
@@ -1072,8 +1091,8 @@ def add_argument(self, *args, **kwargs):
1072
1091
1073
1092
Patches in the level to each created action instance.
1074
1093
1075
- Returns:
1076
- argparse.Action: The created action.
1094
+ :returns: The created action.
1095
+ :rtype: argparse.Action
1077
1096
"""
1078
1097
level = kwargs .pop ('level' , 0 )
1079
1098
action = super (LongHelpArgumentParser , self ).add_argument (* args , ** kwargs )
0 commit comments