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

Replace blacklist/whitelist with denylist/allowlist #524

Merged
merged 2 commits into from Nov 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 18 additions & 1 deletion .github/workflows/test.yml
Expand Up @@ -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
16 changes: 8 additions & 8 deletions doc/source/tips-and-tricks.rst
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
16 changes: 8 additions & 8 deletions toolz/tests/test_inspect_args.py
Expand Up @@ -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('__'):
Expand All @@ -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

Expand Down