@@ -185,6 +185,7 @@ class ConfigurationParser:
185185 'match' ,
186186 'match-dir' ,
187187 'ignore-decorators' ,
188+ 'ignore-self-only-init' ,
188189 )
189190 BASE_ERROR_SELECTION_OPTIONS = ('ignore' , 'select' , 'convention' )
190191
@@ -195,6 +196,7 @@ class ConfigurationParser:
195196 "property,cached_property,functools.cached_property"
196197 )
197198 DEFAULT_CONVENTION = conventions .pep257
199+ DEFAULT_IGNORE_SELF_ONLY_INIT = False
198200
199201 PROJECT_CONFIG_FILES = (
200202 'setup.cfg' ,
@@ -301,6 +303,7 @@ def _get_property_decorators(conf):
301303 list (config .checked_codes ),
302304 ignore_decorators ,
303305 property_decorators ,
306+ config .ignore_self_only_init ,
304307 )
305308 else :
306309 config = self ._get_config (os .path .abspath (name ))
@@ -313,6 +316,7 @@ def _get_property_decorators(conf):
313316 list (config .checked_codes ),
314317 ignore_decorators ,
315318 property_decorators ,
319+ config .ignore_self_only_init ,
316320 )
317321
318322 # --------------------------- Private Methods -----------------------------
@@ -514,9 +518,13 @@ def _merge_configuration(self, parent_config, child_options):
514518 'match_dir' ,
515519 'ignore_decorators' ,
516520 'property_decorators' ,
521+ 'ignore_self_only_init' ,
517522 ):
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 )
520528 )
521529 return CheckConfiguration (** kwargs )
522530
@@ -553,6 +561,7 @@ def _create_check_config(cls, options, use_defaults=True):
553561 'match_dir' : "MATCH_DIR_RE" ,
554562 'ignore_decorators' : "IGNORE_DECORATORS_RE" ,
555563 'property_decorators' : "PROPERTY_DECORATORS" ,
564+ 'ignore_self_only_init' : "IGNORE_SELF_ONLY_INIT" ,
556565 }
557566 for key , default in defaults .items ():
558567 kwargs [key ] = (
@@ -849,6 +858,12 @@ def _create_option_parser(cls):
849858 'basic list previously set by --select, --ignore '
850859 'or --convention.' ,
851860 )
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+ )
852867
853868 parser .add_option_group (check_group )
854869
@@ -916,6 +931,7 @@ def _create_option_parser(cls):
916931 'match_dir' ,
917932 'ignore_decorators' ,
918933 'property_decorators' ,
934+ 'ignore_self_only_init' ,
919935 ),
920936)
921937
0 commit comments