diff --git a/ast_generator/ast_generator.py b/ast_generator/ast_generator.py index b588ff5..388a2ae 100644 --- a/ast_generator/ast_generator.py +++ b/ast_generator/ast_generator.py @@ -60,8 +60,8 @@ class AstGenerator: self.bool_op_options, self.bool_op_cutoffs, self.bool_op_numline = ( self.get_numberlines('expression-weights', - ['comparison', 'logical', 'brackets', 'unary'], - [['less-than-or-equal', 'greater-than-or-equal', 'less-than', 'greater-than'], [], [], ['noop', 'negation']])) + ['brackets', 'comparison', 'logical', 'unary'], + excluded_values=[[], ['less-than-or-equal', 'greater-than-or-equal', 'less-than', 'greater-than'], [], ['noop', 'negation']])) self.bool_unary = ['not'] self.float_op_options, self.float_op_cutoffs, self.float_op_numline = ( @@ -80,7 +80,7 @@ class AstGenerator: ['brackets', 'comparison'], [[], []])) - def get_numberlines(self, settings_section: str, subsettings: list[str], excluded_values: list[list[str or None]]): + def get_numberlines(self, settings_section: str, subsettings: list[str], excluded_values): assert len(subsettings) == len(excluded_values) number_line = 0 @@ -103,6 +103,12 @@ class AstGenerator: else: raise TypeError("invalid setting type. Found " + str(value) + " instead of expected int or dict") + for v in range(len(settings)): + for i in excluded_values: + for j in i: + if j in settings[v]: + settings[v].pop(j) + for v in settings: if isinstance(v, dict): for key, value in v.items():