diff options
author | TakeshiMusgrave <tkm45@cornell.edu> | 2022-04-07 12:14:12 -0400 |
---|---|---|
committer | TakeshiMusgrave <tkm45@cornell.edu> | 2022-04-08 11:53:47 -0400 |
commit | e8e48fa82bdce3f0c1da0693148867befa221de7 (patch) | |
tree | 1f566407bb35172858ec30c85b851bcd804c8933 /test/lint/lint-python-mutable-default-parameters.sh | |
parent | 38d3d0bfc4cae6b31c5ac30f9b0da458bd9a9e57 (diff) | |
download | bitcoin-e8e48fa82bdce3f0c1da0693148867befa221de7.tar.xz |
Converted lint-python-mutable-default-parameters.sh to python
Change permission
Change argument so that it's compatiable with python 3.6
Change comment to docstring
Remove .split, .append, .extend calls. Remove 'output' variable assignment
Diffstat (limited to 'test/lint/lint-python-mutable-default-parameters.sh')
-rwxr-xr-x | test/lint/lint-python-mutable-default-parameters.sh | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/test/lint/lint-python-mutable-default-parameters.sh b/test/lint/lint-python-mutable-default-parameters.sh deleted file mode 100755 index 1f9f035d30..0000000000 --- a/test/lint/lint-python-mutable-default-parameters.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (c) 2019 The Bitcoin Core developers -# Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. -# -# Detect when a mutable list or dict is used as a default parameter value in a Python function. - -export LC_ALL=C -EXIT_CODE=0 -OUTPUT=$(git grep -E '^\s*def [a-zA-Z0-9_]+\(.*=\s*(\[|\{)' -- "*.py") -if [[ ${OUTPUT} != "" ]]; then - echo "A mutable list or dict seems to be used as default parameter value:" - echo - echo "${OUTPUT}" - echo - cat << EXAMPLE -This is how mutable list and dict default parameter values behave: - ->>> def f(i, j=[], k={}): -... j.append(i) -... k[i] = True -... return j, k -... ->>> f(1) -([1], {1: True}) ->>> f(1) -([1, 1], {1: True}) ->>> f(2) -([1, 1, 2], {1: True, 2: True}) - -The intended behaviour was likely: - ->>> def f(i, j=None, k=None): -... if j is None: -... j = [] -... if k is None: -... k = {} -... j.append(i) -... k[i] = True -... return j, k -... ->>> f(1) -([1], {1: True}) ->>> f(1) -([1], {1: True}) ->>> f(2) -([2], {2: True}) -EXAMPLE - EXIT_CODE=1 -fi -exit ${EXIT_CODE} |