ok, how about taking the shorter branch first here? I.e. if field.alias is None:
Also, what do you think about defining three small functions adding semantics and hiding the lowest level branching?
Names can be made more descriptive, but with this it would read something like:
if field.alias is None:
# return [column] if no error
matched = _check_non_alias(df, column, matching_columns_in_df, optional)
continue
if field.regex:
matched = cls._check_alias_regex(df, column, matching_columns_in_df, optional)
else:
# returns [field.alias] if no error
matched = cls._check_alias(df, column, matching_columns_in_df, optional)
matching_columns_in_df.extend(matched)
(Here these are class methods since cls is used in the message.)
It might also help testing to be more unit-y, i.e, testing each individual _check function.
Originally posted by @pierreprecis in #5 (comment)
ok, how about taking the shorter branch first here? I.e.
if field.alias is None:Also, what do you think about defining three small functions adding semantics and hiding the lowest level branching?
Names can be made more descriptive, but with this it would read something like:
(Here these are class methods since
clsis used in the message.)It might also help testing to be more unit-y, i.e, testing each individual
_checkfunction.Originally posted by @pierreprecis in #5 (comment)