From b736708ee78a85cbbf8e20ae26ae42683c9ebef8 Mon Sep 17 00:00:00 2001 From: Erin O'Connell Date: Sun, 24 Jun 2018 22:46:03 -0600 Subject: [PATCH] add click option for --safety-ignore instead of parsing it out of args --- pipenv/cli.py | 16 ++++++++++++++-- pipenv/core.py | 11 ++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/pipenv/cli.py b/pipenv/cli.py index 4ff57353..7bbea860 100644 --- a/pipenv/cli.py +++ b/pipenv/cli.py @@ -694,6 +694,12 @@ def run(command, args, three=None, python=False): default=False, help="Given a code path, show potentially unused dependencies.", ) +@option( + '--safety-ignore', + is_flag=True, + default=False, + help="Ignore specified packages when doing the safety check" +) @argument('args', nargs=-1) def check( three=None, @@ -701,12 +707,18 @@ def check( system=False, unused=False, style=False, + safety_ignore=False, args=None, ): from .core import do_check - + print(safety_ignore) do_check( - three=three, python=python, system=system, unused=unused, args=args + three=three, + python=python, + system=system, + unused=unused, + safety_ignore=safety_ignore, + args=args ) diff --git a/pipenv/core.py b/pipenv/core.py index c7339630..5f2d691e 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -2338,7 +2338,7 @@ def do_run(command, args, three=None, python=False): do_run_posix(script, command=command) -def do_check(three=None, python=False, system=False, unused=False, args=None): +def do_check(three=None, python=False, system=False, unused=False, safety_ignore=False,args=None): if not system: # Ensure that virtualenv is available. ensure_project(three=three, python=python, validate=False, warn=False) @@ -2409,12 +2409,9 @@ def do_check(three=None, python=False, system=False, unused=False, args=None): python = which('python') else: python = system_which('python') - try: - if '--safety-ignore' in args[0]: - ignore = '-i ' + ' -i'.join(args[1:]) - else: - ignore = '' - except IndexError: + if safety_ignore: + ignore = '-i ' + ' -i '.join(args) + else: ignore = '' c = delegator.run( '"{0}" {1} check --json --key=1ab8d58f-5122e025-83674263-bc1e79e0 {2}'.format(