@@ -185,6 +185,7 @@ class ConfigurationParser:
185
185
'match' ,
186
186
'match-dir' ,
187
187
'ignore-decorators' ,
188
+ 'ignore-self-only-init' ,
188
189
)
189
190
BASE_ERROR_SELECTION_OPTIONS = ('ignore' , 'select' , 'convention' )
190
191
@@ -195,6 +196,7 @@ class ConfigurationParser:
195
196
"property,cached_property,functools.cached_property"
196
197
)
197
198
DEFAULT_CONVENTION = conventions .pep257
199
+ DEFAULT_IGNORE_SELF_ONLY_INIT = False
198
200
199
201
PROJECT_CONFIG_FILES = (
200
202
'setup.cfg' ,
@@ -301,6 +303,7 @@ def _get_property_decorators(conf):
301
303
list (config .checked_codes ),
302
304
ignore_decorators ,
303
305
property_decorators ,
306
+ config .ignore_self_only_init ,
304
307
)
305
308
else :
306
309
config = self ._get_config (os .path .abspath (name ))
@@ -313,6 +316,7 @@ def _get_property_decorators(conf):
313
316
list (config .checked_codes ),
314
317
ignore_decorators ,
315
318
property_decorators ,
319
+ config .ignore_self_only_init ,
316
320
)
317
321
318
322
# --------------------------- Private Methods -----------------------------
@@ -514,9 +518,13 @@ def _merge_configuration(self, parent_config, child_options):
514
518
'match_dir' ,
515
519
'ignore_decorators' ,
516
520
'property_decorators' ,
521
+ 'ignore_self_only_init' ,
517
522
):
518
- kwargs [key ] = getattr (child_options , key ) or getattr (
519
- parent_config , key
523
+ child_value = getattr (child_options , key )
524
+ kwargs [key ] = (
525
+ child_value
526
+ if child_value is not None
527
+ else getattr (parent_config , key )
520
528
)
521
529
return CheckConfiguration (** kwargs )
522
530
@@ -553,6 +561,7 @@ def _create_check_config(cls, options, use_defaults=True):
553
561
'match_dir' : "MATCH_DIR_RE" ,
554
562
'ignore_decorators' : "IGNORE_DECORATORS_RE" ,
555
563
'property_decorators' : "PROPERTY_DECORATORS" ,
564
+ 'ignore_self_only_init' : "IGNORE_SELF_ONLY_INIT" ,
556
565
}
557
566
for key , default in defaults .items ():
558
567
kwargs [key ] = (
@@ -849,6 +858,12 @@ def _create_option_parser(cls):
849
858
'basic list previously set by --select, --ignore '
850
859
'or --convention.' ,
851
860
)
861
+ add_check (
862
+ '--ignore-self-only-init' ,
863
+ default = None ,
864
+ action = 'store_true' ,
865
+ help = 'ignore __init__ methods which only have a self param.' ,
866
+ )
852
867
853
868
parser .add_option_group (check_group )
854
869
@@ -916,6 +931,7 @@ def _create_option_parser(cls):
916
931
'match_dir' ,
917
932
'ignore_decorators' ,
918
933
'property_decorators' ,
934
+ 'ignore_self_only_init' ,
919
935
),
920
936
)
921
937
0 commit comments