@@ -26,173 +26,173 @@ def parse_arguments(args: Optional[List[str]]) -> Args:
2626
2727 # Docs: https://docs.python.org/3/library/argparse.html
2828 parser = argparse .ArgumentParser ()
29- parser .add_argument (" paths" , help = " Paths where to search for python files" , nargs = "+" )
29+ parser .add_argument (' paths' , help = ' Paths where to search for python files' , nargs = '+' )
3030 parser .add_argument (
31- " --fix" ,
32- help = " Automatically remove detected unused code expressions from the code base." ,
33- action = " store_true" ,
31+ ' --fix' ,
32+ help = ' Automatically remove detected unused code expressions from the code base.' ,
33+ action = ' store_true' ,
3434 default = False ,
3535 )
3636 parser .add_argument (
37- " --dry" ,
38- help = " Show changes which would be made in files with --fix option." ,
39- nargs = "*" ,
40- action = " append" ,
41- default = [[" __all_files__" ]],
37+ ' --dry' ,
38+ help = ' Show changes which would be made in files with --fix option.' ,
39+ nargs = '*' ,
40+ action = ' append' ,
41+ default = [[' __all_files__' ]],
4242 type = str ,
4343 )
4444 parser .add_argument (
45- " --exclude" ,
46- help = " Filenames (or path expressions), which will be completely skipped without being analysed." ,
47- nargs = "*" ,
48- action = " append" ,
45+ ' --exclude' ,
46+ help = ' Filenames (or path expressions), which will be completely skipped without being analysed.' ,
47+ nargs = '*' ,
48+ action = ' append' ,
4949 default = [],
5050 type = str ,
5151 )
5252 parser .add_argument (
53- " --ignore-names" ,
53+ ' --ignore-names' ,
5454 help = (
55- " Removes provided list of names from the output. "
56- " Regexp expressions to match multiple names can also be provided."
55+ ' Removes provided list of names from the output. '
56+ ' Regexp expressions to match multiple names can also be provided.'
5757 ),
58- nargs = "*" ,
59- action = " append" ,
58+ nargs = '*' ,
59+ action = ' append' ,
6060 default = [],
6161 type = str ,
6262 )
6363 parser .add_argument (
64- " --ignore-bodies-of" ,
65- help = " Ignores body of an expression if its name matches any of the provided names." ,
66- nargs = "*" ,
67- action = " append" ,
64+ ' --ignore-bodies-of' ,
65+ help = ' Ignores body of an expression if its name matches any of the provided names.' ,
66+ nargs = '*' ,
67+ action = ' append' ,
6868 default = [],
6969 type = str ,
7070 )
7171 parser .add_argument (
72- " --ignore-bodies-if-decorated-with" ,
73- help = " Ignores body of an expression if its decorated with one of the provided decorator names." ,
74- nargs = "*" ,
75- action = " append" ,
72+ ' --ignore-bodies-if-decorated-with' ,
73+ help = ' Ignores body of an expression if its decorated with one of the provided decorator names.' ,
74+ nargs = '*' ,
75+ action = ' append' ,
7676 default = [],
7777 type = str ,
7878 )
7979 parser .add_argument (
80- " --ignore-bodies-if-inherits-from" ,
81- help = " Ignores body of a class if it inherits from any of the provided class names." ,
82- nargs = "*" ,
83- action = " append" ,
80+ ' --ignore-bodies-if-inherits-from' ,
81+ help = ' Ignores body of a class if it inherits from any of the provided class names.' ,
82+ nargs = '*' ,
83+ action = ' append' ,
8484 default = [],
8585 type = str ,
8686 )
8787 parser .add_argument (
88- " --ignore-definitions" ,
88+ ' --ignore-definitions' ,
8989 help = (
90- " Ignores definition (including name and body) if a "
91- " name of an expression matches any of the provided ones."
90+ ' Ignores definition (including name and body) if a '
91+ ' name of an expression matches any of the provided ones.'
9292 ),
93- nargs = "*" ,
94- action = " append" ,
93+ nargs = '*' ,
94+ action = ' append' ,
9595 default = [],
9696 type = str ,
9797 )
9898 parser .add_argument (
99- " --ignore-definitions-if-inherits-from" ,
99+ ' --ignore-definitions-if-inherits-from' ,
100100 help = (
101- " Ignores definition (including name and body) of a class if "
102- " it inherits from any of the provided class names."
101+ ' Ignores definition (including name and body) of a class if '
102+ ' it inherits from any of the provided class names.'
103103 ),
104- nargs = "*" ,
105- action = " append" ,
104+ nargs = '*' ,
105+ action = ' append' ,
106106 default = [],
107107 type = str ,
108108 )
109109 parser .add_argument (
110- " --ignore-definitions-if-decorated-with" ,
110+ ' --ignore-definitions-if-decorated-with' ,
111111 help = (
112- " Ignores definition (including name and body) of an expression, "
113- " which is decorated with any of the provided decorator names."
112+ ' Ignores definition (including name and body) of an expression, '
113+ ' which is decorated with any of the provided decorator names.'
114114 ),
115- nargs = "*" ,
116- action = " append" ,
115+ nargs = '*' ,
116+ action = ' append' ,
117117 default = [],
118118 type = str ,
119119 )
120120
121121 parser .add_argument (
122- " --ignore-if-decorated-with" ,
123- help = " Ignores both the name and its definition if its decorated with one of the provided decorator names." ,
124- nargs = "*" ,
125- action = " append" ,
122+ ' --ignore-if-decorated-with' ,
123+ help = ' Ignores both the name and its definition if its decorated with one of the provided decorator names.' ,
124+ nargs = '*' ,
125+ action = ' append' ,
126126 default = [],
127127 type = str ,
128128 )
129129 parser .add_argument (
130- " --ignore-if-inherits-from" ,
131- help = " Ignores both the name and its definition if the class inerits from the provided class name." ,
132- nargs = "*" ,
133- action = " append" ,
130+ ' --ignore-if-inherits-from' ,
131+ help = ' Ignores both the name and its definition if the class inerits from the provided class name.' ,
132+ nargs = '*' ,
133+ action = ' append' ,
134134 default = [],
135135 type = str ,
136136 )
137137
138138 parser .add_argument (
139- " --ignore-names-if-inherits-from" ,
140- help = " Ignores names of classes, which inherit from provided class names." ,
141- nargs = "*" ,
142- action = " append" ,
139+ ' --ignore-names-if-inherits-from' ,
140+ help = ' Ignores names of classes, which inherit from provided class names.' ,
141+ nargs = '*' ,
142+ action = ' append' ,
143143 default = [],
144144 type = str ,
145145 )
146146 parser .add_argument (
147- " --ignore-names-if-decorated-with" ,
148- help = " Ignores names of an expression, which is decorated with one of the provided decorator names." ,
149- nargs = "*" ,
150- action = " append" ,
147+ ' --ignore-names-if-decorated-with' ,
148+ help = ' Ignores names of an expression, which is decorated with one of the provided decorator names.' ,
149+ nargs = '*' ,
150+ action = ' append' ,
151151 default = [],
152152 type = str ,
153153 )
154154
155155 parser .add_argument (
156- " --ignore-names-in-files" ,
157- help = " Ignores unused names in files, which filenames match provided path expressions." ,
158- nargs = "*" ,
159- action = " append" ,
156+ ' --ignore-names-in-files' ,
157+ help = ' Ignores unused names in files, which filenames match provided path expressions.' ,
158+ nargs = '*' ,
159+ action = ' append' ,
160160 default = [],
161161 type = str ,
162162 )
163163
164164 parser .add_argument (
165- " --no-color" ,
166- help = " Turn off colors in the output" ,
167- action = " store_true" ,
165+ ' --no-color' ,
166+ help = ' Turn off colors in the output' ,
167+ action = ' store_true' ,
168168 default = False ,
169169 )
170170
171171 parser .add_argument (
172- " --quiet" ,
173- help = " Does not output anything. Makefile still fails with exit code 1 if unused names are found." ,
174- action = " store_true" ,
172+ ' --quiet' ,
173+ help = ' Does not output anything. Makefile still fails with exit code 1 if unused names are found.' ,
174+ action = ' store_true' ,
175175 default = False ,
176176 )
177177
178178 parser .add_argument (
179- " --count" ,
180- help = " Provides the count of the detected unused names instead of printing them all out." ,
181- action = " store_true" ,
179+ ' --count' ,
180+ help = ' Provides the count of the detected unused names instead of printing them all out.' ,
181+ action = ' store_true' ,
182182 default = False ,
183183 )
184184 parser .add_argument (
185- "-v" ,
186- " --verbose" ,
187- help = " Shows logs useful for debuging" ,
188- action = " store_true" ,
185+ '-v' ,
186+ ' --verbose' ,
187+ help = ' Shows logs useful for debuging' ,
188+ action = ' store_true' ,
189189 default = False ,
190190 )
191191
192192 parsed_args = parser .parse_args (args ).__dict__
193193
194194 for arg_name , arg_value in parsed_args .items ():
195- if isinstance (arg_value , list ) and arg_name != " paths" :
195+ if isinstance (arg_value , list ) and arg_name != ' paths' :
196196 parsed_args [arg_name ] = flatten_lists_of_comma_separated_values (parsed_args .get (arg_name ))
197197
198198 # Extend the Args with the values provided in the pyproject.toml
@@ -201,12 +201,12 @@ def parse_arguments(args: Optional[List[str]]) -> Args:
201201 parsed_args [key ].extend (item )
202202
203203 # Show changes for only provided files instead of all
204- if len (parsed_args [" dry" ]) > 1 or " --dry" not in args :
205- parsed_args [" dry" ].remove (" __all_files__" )
204+ if len (parsed_args [' dry' ]) > 1 or ' --dry' not in args :
205+ parsed_args [' dry' ].remove (' __all_files__' )
206206
207207 # Do not fix if dry option is provided:
208- if parsed_args [" dry" ]:
209- parsed_args [" fix" ] = False
208+ if parsed_args [' dry' ]:
209+ parsed_args [' fix' ] = False
210210
211211 return Args (** parsed_args )
212212
@@ -217,13 +217,13 @@ def parse_pyproject_toml() -> Dict[str, Any]:
217217 If parsing fails, will raise a tomllib.TOMLDecodeError.
218218 Copied from: https://github.com/psf/black/blob/01b8d3d4095ebdb91d0d39012a517931625c63cb/src/black/files.py#LL113C15-L113C15
219219 """
220- pyproject_toml_filename = " pyproject.toml"
220+ pyproject_toml_filename = ' pyproject.toml'
221221 if not os .path .isfile (pyproject_toml_filename ):
222222 return {}
223223
224- with open (pyproject_toml_filename , "rb" ) as f :
224+ with open (pyproject_toml_filename , 'rb' ) as f :
225225 pyproject_toml = tomllib .load (f )
226226
227- config : Dict [str , Any ] = pyproject_toml .get (" tool" , {}).get (" deadcode" , {})
228- config = {k .replace ("--" , "" ).replace ("-" , "_" ): v for k , v in config .items ()}
227+ config : Dict [str , Any ] = pyproject_toml .get (' tool' , {}).get (' deadcode' , {})
228+ config = {k .replace ('--' , '' ).replace ('-' , '_' ): v for k , v in config .items ()}
229229 return config
0 commit comments