From e455f6c637ee82bc170c04b5fe6905553054cce6 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Fri, 5 Nov 2021 22:47:33 -0500 Subject: [PATCH 1/2] Replace blacklist/whitelist with denylist/allowlist Closes #508 --- .github/workflows/test.yml | 19 ++++++++++++++++++- doc/source/tips-and-tricks.rst | 16 ++++++++-------- toolz/tests/test_inspect_args.py | 16 ++++++++-------- 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a1f52b3d..6759d2f3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,7 +30,24 @@ jobs: coverage run -m pytest --doctest-modules toolz/ pytest bench/ pep8 --ignore="E731,W503,E402" --exclude=conf.py,tests,examples,bench -r --show-source . - - name: Coverate + - name: Coverage + env: + GITHUB_TOKEN: ${{ secrets.github_token }} + COVERALLS_FLAG_NAME: ${{ matrix.python-version}} + COVERALLS_PARALLEL: true if: (! contains(matrix.python-version, 'pypy')) run: | coverage report --show-missing --fail-under=100 + pip install coveralls + coverage report --show-missing + coveralls --service=github + +finish: + needs: test + runs-on: ubuntu-latest + steps: + - name: Coveralls Finished + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.github_token }} + parallel-finished: true diff --git a/doc/source/tips-and-tricks.rst b/doc/source/tips-and-tricks.rst index 3c33608d..0a5b88d9 100644 --- a/doc/source/tips-and-tricks.rst +++ b/doc/source/tips-and-tricks.rst @@ -6,17 +6,17 @@ a part of toolz's standard offerings. This section presents a few of these recipes. -* .. function:: pick(whitelist, dictionary) +* .. function:: pick(allowlist, dictionary) Return a subset of the provided dictionary with keys contained in the - whitelist. + allowlist. :: from toolz import keyfilter - def pick(whitelist, d): - return keyfilter(lambda k: k in whitelist, d) + def pick(allowlist, d): + return keyfilter(lambda k: k in allowlist, d) Example: @@ -26,17 +26,17 @@ a few of these recipes. {'a': 1, 'b': 2} -* .. function:: omit(blacklist, dictionary) +* .. function:: omit(denylist, dictionary) Return a subset of the provided dictionary with keys *not* contained in the - blacklist. + denylist. :: from toolz import keyfilter - def omit(blacklist, d): - return keyfilter(lambda k: k not in blacklist, d) + def omit(denylist, d): + return keyfilter(lambda k: k not in denylist, d) Example: diff --git a/toolz/tests/test_inspect_args.py b/toolz/tests/test_inspect_args.py index da985044..93408eb5 100644 --- a/toolz/tests/test_inspect_args.py +++ b/toolz/tests/test_inspect_args.py @@ -386,16 +386,16 @@ def test_introspect_builtin_modules(): mods = [builtins, functools, itertools, operator, toolz, toolz.functoolz, toolz.itertoolz, toolz.dicttoolz, toolz.recipes] - blacklist = set() + denylist = set() - def add_blacklist(mod, attr): + def add_denylist(mod, attr): if hasattr(mod, attr): - blacklist.add(getattr(mod, attr)) + denylist.add(getattr(mod, attr)) - add_blacklist(builtins, 'basestring') - add_blacklist(builtins, 'NoneType') - add_blacklist(builtins, '__metaclass__') - add_blacklist(builtins, 'sequenceiterator') + add_denylist(builtins, 'basestring') + add_denylist(builtins, 'NoneType') + add_denylist(builtins, '__metaclass__') + add_denylist(builtins, 'sequenceiterator') def is_missing(modname, name, func): if name.startswith('_') and not name.startswith('__'): @@ -412,7 +412,7 @@ def is_missing(modname, name, func): and func.__module__ is not None and modname in func.__module__ and is_partial_args(func, (), {}) is not True - and func not in blacklist) + and func not in denylist) except AttributeError: return False From 28620de7db7f509cbb26a3bc8303741d15df1260 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Fri, 5 Nov 2021 22:50:07 -0500 Subject: [PATCH 2/2] oops --- .github/workflows/test.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6759d2f3..6c1303e7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,12 +42,12 @@ jobs: coverage report --show-missing coveralls --service=github -finish: - needs: test - runs-on: ubuntu-latest - steps: - - name: Coveralls Finished - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.github_token }} - parallel-finished: true + finish: + needs: test + runs-on: ubuntu-latest + steps: + - name: Coveralls Finished + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.github_token }} + parallel-finished: true