Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not use a default parameter which is an empty list #14

Open
metzm opened this issue Sep 21, 2023 · 0 comments
Open

do not use a default parameter which is an empty list #14

metzm opened this issue Sep 21, 2023 · 0 comments

Comments

@metzm
Copy link

metzm commented Sep 21, 2023

Relevant here: https://github.com/mundialis/grass-gis-helpers/blob/main/src/grass_gis_helpers/cleanup.py#L27

From stackoverflow:

Sometimes it seems natural to have a default parameter which is an empty list. However, Python produces unexpected behavior in these situations.

Use

def general_cleanup(
    rm_rasters=None,
    rm_vectors=None,
    rm_files=None,
    rm_dirs=None,
    rm_groups=None,
    rm_groups_wo_rasters=None,
    rm_regions=None,
    rm_strds=None,
    orig_region=None,
    rm_mask=False,
):

instead and add tests if the arguments are not None and a list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant