Back to Pipenv

Initiative C — Routine Parameter Inventory

docs/dev/initiative-c-params.md

2026.8.044.7 KB
Original Source

Initiative C — Routine Parameter Inventory

This document is a temporary working artefact for Initiative C of the 2026-05 modernization plan (see docs/dev/modernization-plan.md, task T_C.2). It inventories the function signatures of pipenv's routine entry points and their internal helpers, buckets each parameter into a semantic group, and surfaces patterns that motivate the proposed RoutineContext dataclass in task T_C.3.

The threshold for inclusion in the main table is more than 3 parameters besides project. Trivial-arity helpers and routines that are essentially (project) plus 1-2 simple flags are noted in an appendix.

This file will be deleted once T_C.3 absorbs its content into the RoutineContext design proposal.

pipenv/core.py does not exist in the current tree (the historical core.py was decomposed into pipenv/routines/*.py and pipenv/utils/* by earlier modernization work), so this inventory is sourced entirely from pipenv/routines/.

Semantic groups

Parameters are bucketed into one of six groups:

  • install_policy — flags governing install behaviour: pre, deploy, skip_lock, ignore_pipfile, lockfile_only, clear, lock, lock_only, dry_run.
  • target_env — what Python / where to install: system, allow_global, python, pypi_mirror, site_packages.
  • package_selection — which packages: packages, editable_packages, pipfile_categories, categories, dev, index, index_url, index_name, package_args, package_name, dev_only, all, all_dev.
  • execution_options — how to run: extra_pip_args, requirementstxt, requirements_directory, requirements_dir, requirements_file, no_deps, ignore_hashes, use_pep517, from_pipfile, no_lock, include_hashes, include_markers, include_index, write, quiet, bare, verbose, outdated, auto_install.
  • state_flags — flags that describe a sub-routine's intent: perform_upgrades, warn, has_package_args, explicitly_requested, lock_only (in helper context), scan (in do_check), legacy_mode, use_installed, use_lockfile.
  • other — doesn't fit; explained in notes. Includes data-flow params passed between helpers (e.g. reverse_deps, lockfile, original_lockfile, procs, sources, ctx, old_hash, new_hash, new_version, resolved_default_deps, requested_packages).

Where a parameter could plausibly belong to two groups, it is classified by the role it plays in the routine's intent rather than its type. package_args is always package_selection even though it is sometimes paired with state flags. Output-formatting toggles (bare, quiet, verbose) go in execution_options because they describe how to run, not what to install.

Summary by semantic group

Distinct-parameter-name counts across all in-scope functions (a parameter name is counted once per appearance row in the per-routine table):

GroupRow count
install_policy36
target_env50
package_selection54
execution_options57
state_flags9
other34
Total240

Per-routine row counts:

RoutineRows
install.do_install15
install.handle_new_packages10
install.handle_lockfile9
install.handle_outdated_lockfile9
install.handle_missing_lockfile4
install.do_install_validations10
install.do_install_dependencies9
install.batch_install_iteration8
install.batch_install10
install.do_init9
update.do_update17
update.check_version_conflicts4
update._process_package_args9
update._resolve_and_update_lockfile9
update._clean_unused_dependencies5
update.upgrade10
uninstall.do_uninstall11
lock.do_lock8
sync.do_sync10
requirements.generate_requirements8
check.do_check18
audit.do_audit20
scan.do_scan18
Total240

Per-routine parameter table

install.do_install (pipenv/routines/install.py)

ParameterTypeDefaultSemantic groupNotes
packageslist[str] / FalseFalsepackage_selectionCLI positional; falsy default sentinel.
editable_packageslist[str] / FalseFalsepackage_selection-e packages.
indexstr / FalseFalsepackage_selection--index URL or named source.
devboolFalsepackage_selectionRoutes to [dev-packages].
pythonstr / FalseFalsetarget_env--python interpreter selector.
pypi_mirrorstr | NoneNonetarget_envMirror URL; duplicated across nearly every routine.
systemboolFalsetarget_env--system install target.
ignore_pipfileboolFalseinstall_policyUse lockfile only.
requirementstxtstr / FalseFalseexecution_optionsPath or URL to a requirements file.
preboolFalseinstall_policyAllow pre-releases.
deployboolFalseinstall_policy--deploy: fail on hash mismatch.
site_packagesbool | NoneNonetarget_envEnable venv site-packages.
extra_pip_argslist[str] | NoneNoneexecution_optionsPassthrough to pip.
pipfile_categorieslist[str] | NoneNonepackage_selectionCategories to target.
skip_lockboolFalseinstall_policySkip do_lock step.

install.handle_new_packages

ParameterTypeDefaultSemantic groupNotes
packageslist[str]package_selectionRequired positional.
editable_packageslist[str]package_selectionRequired positional.
devboolpackage_selectionRequired positional.
preboolinstall_policy
systembooltarget_env
pypi_mirrorstr | Nonetarget_env
extra_pip_argslist[str] | Noneexecution_options
pipfile_categorieslist[str] | Nonepackage_selection
perform_upgradesboolTruestate_flagsSub-routine intent: also call do_update.
indexstr | NoneNonepackage_selection

install.handle_lockfile

ParameterTypeDefaultSemantic groupNotes
packageslist[str]package_selectionUsed to decide whether to early-return.
ignore_pipfileboolinstall_policy
skip_lockboolinstall_policy
systembooltarget_env
allow_globalbooltarget_envMirrors system in calling context.
deployboolinstall_policy
preboolinstall_policy
pypi_mirrorstr | Nonetarget_env
categorieslist[str] | Nonepackage_selection

install.handle_outdated_lockfile

ParameterTypeDefaultSemantic groupNotes
packageslist[str]package_selection
old_hashstrotherLockfile-hash data-flow value.
new_hashstrotherLockfile-hash data-flow value.
systembooltarget_env
allow_globalbooltarget_env
skip_lockboolinstall_policy
preboolinstall_policy
pypi_mirrorstr | Nonetarget_env
categorieslist[str] | Nonepackage_selection

install.handle_missing_lockfile

ParameterTypeDefaultSemantic groupNotes
systembooltarget_env
allow_globalbooltarget_env
preboolinstall_policy
pypi_mirrorstr | Nonetarget_env

install.do_install_validations

ParameterTypeDefaultSemantic groupNotes
package_argslist[str]package_selectionCombined positional + editable list.
requirements_directorystrexecution_optionsTemp dir path.
devboolFalsepackage_selection
systemboolFalsetarget_env
ignore_pipfileboolFalseinstall_policy
requirementstxtstr | boolFalseexecution_options
preboolFalseinstall_policy
deployboolFalseinstall_policy
categorieslist[str] | NoneNonepackage_selectionReceives pipfile_categories from do_install.
skip_lockboolFalseinstall_policy

install.do_install_dependencies

ParameterTypeDefaultSemantic groupNotes
devboolFalsepackage_selection
bareboolFalseexecution_optionsOutput verbosity toggle.
allow_globalboolFalsetarget_env
ignore_hashesboolFalseexecution_optionspip flag passthrough.
requirements_dirstr | NoneNoneexecution_options
pypi_mirrorstr | NoneNonetarget_env
extra_pip_argslist[str] | NoneNoneexecution_options
categorieslist[str] | NoneNonepackage_selection
skip_lockboolFalseinstall_policy

install.batch_install_iteration

ParameterTypeDefaultSemantic groupNotes
deps_to_installlist[tuple]otherPer-call data-flow payload.
sourceslist[dict]otherIndex source list.
procsqueue.QueueotherShared subprocess queue.
requirements_dirstrexecution_options
no_depsboolTrueexecution_options
ignore_hashesboolFalseexecution_options
allow_globalboolFalsetarget_env
extra_pip_argslist[str] | NoneNoneexecution_options

install.batch_install

ParameterTypeDefaultSemantic groupNotes
deps_listlist[tuple]otherResolved dependency list.
lockfile_sectiondictotherSection of lockfile (default/develop).
procsqueue.Queueother
requirements_dirstrexecution_options
no_depsboolTrueexecution_options
ignore_hashesboolFalseexecution_options
allow_globalboolFalsetarget_env
pypi_mirrorstr | NoneNonetarget_env
sequential_depslist[tuple] | NoneNoneotherEditable/VCS subset.
extra_pip_argslist[str] | NoneNoneexecution_options

install.do_init

ParameterTypeDefaultSemantic groupNotes
packageslist[str] | NoneNonepackage_selection
allow_globalboolFalsetarget_env
ignore_pipfileboolFalseinstall_policy
systemboolFalsetarget_env
deployboolFalseinstall_policy
preboolFalseinstall_policy
pypi_mirrorstr | NoneNonetarget_env
skip_lockboolFalseinstall_policy
categorieslist[str] | NoneNonepackage_selection

update.do_update

ParameterTypeDefaultSemantic groupNotes
pythonstr | NoneNonetarget_env
preboolFalseinstall_policy
systemboolFalsetarget_env
packageslist[str] | NoneNonepackage_selection
editable_packageslist[str] | NoneNonepackage_selection
site_packagesboolFalsetarget_env
pypi_mirrorstr | NoneNonetarget_env
devboolFalsepackage_selection
categorieslist[str] | NoneNonepackage_selection
index_urlstr | NoneNonepackage_selection
extra_pip_argslist[str] | NoneNoneexecution_options
quietboolFalseexecution_options
bareboolFalseexecution_options
dry_runbool | NoneNoneinstall_policyTriggers outdated mode when truthy.
outdatedboolFalseexecution_optionsSwitches routine to do_outdated path.
clearboolFalseinstall_policyClear resolver cache.
lock_onlyboolFalseinstall_policyUpdate lockfile without installing.

update.check_version_conflicts

ParameterTypeDefaultSemantic groupNotes
package_namestrpackage_selectionSingle-package context; no project.
new_versionstrotherVersion-string payload.
reverse_depsdict[str, set[tuple[str, str]]]otherReverse-dep map.
lockfiledictotherLockfile data.

update._process_package_args

ParameterTypeDefaultSemantic groupNotes
package_argslist[str]package_selection
pipfile_categorystrpackage_selectionSingle category name (singular).
index_namestr | Nonepackage_selection
reverse_depsdictother
explicitly_requesteddict[str, list]state_flagsTracks which packages were explicitly named.
categorystrpackage_selectionLockfile section (default/develop).
has_package_argsboolstate_flagsCached truthy of package_args for inner logic.
requested_packagesdefaultdict[dict]otherMutable accumulator.
lock_onlyboolFalseinstall_policy

update._resolve_and_update_lockfile

ParameterTypeDefaultSemantic groupNotes
requested_packagesdefaultdictother
pipfile_categorystrpackage_selection
categorystrpackage_selection
package_argslist[str]package_selection
preboolinstall_policy
systembooltarget_env
pypi_mirrorstr | Nonetarget_env
lockfiledictotherMutated in place.
resolved_default_depsdict | NoneNoneotherConstraint payload for non-default categories.

update._clean_unused_dependencies

ParameterTypeDefaultSemantic groupNotes
lockfiledictother
categorystrpackage_selection
full_lock_resolutiondictother
original_lockfiledictother
reverse_depsdict | NoneNoneother

update.upgrade

ParameterTypeDefaultSemantic groupNotes
preboolFalseinstall_policy
systemboolFalsetarget_env
packageslist[str] | NoneNonepackage_selection
editable_packageslist[str] | NoneNonepackage_selection
pypi_mirrorstr | NoneNonetarget_env
index_urlstr | NoneNonepackage_selection
categorieslist[str] | NoneNonepackage_selection
devboolFalsepackage_selection
lock_onlyboolFalseinstall_policy
extra_pip_argslist[str] | NoneNoneexecution_options

uninstall.do_uninstall

ParameterTypeDefaultSemantic groupNotes
packageslist[str] | NoneNonepackage_selection
editable_packageslist[str] | NoneNonepackage_selection
pythonstr / FalseFalsetarget_env
systemboolFalsetarget_env
lockboolFalseinstall_policyRe-run do_lock afterwards.
all_devboolFalsepackage_selectionRemove all [dev-packages].
allboolFalsepackage_selectionPurge entire venv.
preboolFalseinstall_policy
pypi_mirrorstr | NoneNonetarget_env
ctxclick.ContextNoneotherClick context passthrough for error usage.
categorieslist[str] | NoneNonepackage_selection

lock.do_lock

ParameterTypeDefaultSemantic groupNotes
systemboolFalsetarget_env
clearboolFalseinstall_policyClear resolver cache.
preboolFalseinstall_policy
writeboolTrueexecution_optionsWrite to disk or return dict.
quietboolFalseexecution_options
pypi_mirrorstr | NoneNonetarget_env
categorieslist[str] | NoneNonepackage_selection
extra_pip_argslist[str] | NoneNoneexecution_options

sync.do_sync

ParameterTypeDefaultSemantic groupNotes
devboolFalsepackage_selection
pythonstr | NoneNonetarget_env
bareboolFalseexecution_options
clearboolFalseinstall_policy
pypi_mirrorstr | NoneNonetarget_env
systemboolFalsetarget_env
deployboolFalseinstall_policy
extra_pip_argslist[str] | NoneNoneexecution_options
categorieslist[str] | NoneNonepackage_selection
site_packagesboolFalsetarget_env

requirements.generate_requirements

ParameterTypeDefaultSemantic groupNotes
devboolFalsepackage_selection
dev_onlyboolFalsepackage_selection
include_hashesboolFalseexecution_optionsOutput formatting toggle.
include_markersboolTrueexecution_options
categoriesstr""package_selectionComma-separated string (not list).
from_pipfileboolFalseexecution_optionsFilter by Pipfile categories.
no_lockboolFalseexecution_optionsGenerate from Pipfile rather than lockfile.
include_indexboolTrueexecution_options

check.do_check

ParameterTypeDefaultSemantic groupNotes
pythonstr / FalseFalsetarget_env
systemboolFalsetarget_env
dbstr | NoneNoneotherSafety DB URL.
ignorelist[str] | NoneNoneotherCVEs to ignore.
outputstr"screen"execution_options
keystr | NoneNoneotherSafety API key.
quietboolFalseexecution_options
verboseboolFalseexecution_options
exit_codeboolTrueexecution_options
policy_filestr""otherSafety policy file.
save_jsonstr""execution_options
audit_and_monitorboolTrueexecution_options
safety_projectstr | NoneNoneother
pypi_mirrorstr | NoneNonetarget_env
use_installedboolFalsestate_flagsSwitch source between installed and lockfile.
categoriesstr""package_selection
auto_installboolFalseexecution_optionsAuto-install safety package.
scanboolFalsestate_flagsDelegate to do_scan.

audit.do_audit

ParameterTypeDefaultSemantic groupNotes
pythonstr / FalseFalsetarget_env
systemboolFalsetarget_env
outputstr"columns"execution_options
quietboolFalseexecution_options
verboseboolFalseexecution_options
strictboolFalseexecution_options
ignorelist[str] | NoneNoneotherVulnerability IDs to ignore.
fixboolFalseexecution_options
dry_runboolFalseinstall_policy
skip_editableboolFalseexecution_options
no_depsboolFalseexecution_options
local_onlyboolFalseexecution_options
vulnerability_servicestr"pypi"otherBackend selector.
descriptionsboolFalseexecution_options
aliasesboolFalseexecution_options
output_filestr | NoneNoneexecution_options
pypi_mirrorstr | NoneNonetarget_env
categoriesstr""package_selection
use_installedboolFalsestate_flags
use_lockfileboolFalsestate_flags

scan.do_scan

ParameterTypeDefaultSemantic groupNotes
pythonstr / FalseFalsetarget_env
systemboolFalsetarget_env
dbstr | NoneNoneother
ignorelist[str] | NoneNoneother
outputstr"screen"execution_options
keystr | NoneNoneother
quietboolFalseexecution_options
verboseboolFalseexecution_options
exit_codeboolTrueexecution_options
policy_filestr""other
save_jsonstr""execution_options
audit_and_monitorboolTrueexecution_options
safety_projectstr | NoneNoneother
pypi_mirrorstr | NoneNonetarget_env
use_installedboolFalsestate_flags
categoriesstr""package_selection
legacy_modeboolFalsestate_flagsFalls back to old safety CLI.
auto_installboolFalseexecution_options

Routines out of scope (≤3 non-project params, or per-task-spec exclusion)

Per the task spec, the following routines are noted here rather than included in the main table. Counts are non-project parameters.

  • pipenv/routines/clear.py:do_clear — 0 params besides project.
  • pipenv/routines/uninstall.py:do_purge — 3 params (bare, downloads, allow_global).
  • pipenv/routines/uninstall.py:_uninstall_from_environment — 2 params (package, system).
  • pipenv/routines/install.py:install_build_system_packages — 3 params (allow_global, pypi_mirror, requirements_dir).
  • pipenv/routines/install.py:_target_marker_environment — 1 param.
  • pipenv/routines/install.py:_should_use_no_binary — 2 params, takes no project.
  • pipenv/routines/install.py:_cleanup_procs — 1 param.
  • pipenv/routines/lock.py:overwrite_with_default — 2 params, takes no project.
  • pipenv/routines/clean.py:do_clean — 5 params (python, dry_run, bare, pypi_mirror, system); excluded per task spec ("clean" is a routine that doesn't need RoutineContext).
  • pipenv/routines/clean.py:ensure_lockfile — 1 param.
  • pipenv/routines/graph.py:do_graph — 4 params (bare, json, json_tree, reverse); excluded per task spec.
  • pipenv/routines/shell.py:do_shell — 5 params (python, fancy, shell_args, pypi_mirror, quiet); excluded per task spec.
  • pipenv/routines/shell.py:do_run — 5 params (command, args, python, pypi_mirror, system); excluded per task spec (script-execution path, not dependency management).
  • pipenv/routines/shell.py:_run_script_sequence, do_run_posix, do_run_nt, _launch_windows_subprocess — script-sequencing helpers; no project-centric routine context applies.
  • pipenv/routines/outdated.py:do_outdated — 3 params (pypi_mirror, pre, clear).
  • pipenv/routines/outdated.py:_get_lockfile_entry_version — 1 param, no project.
  • pipenv/routines/update.py:get_reverse_dependencies — 1 param (project).
  • pipenv/routines/update.py:_locked_version_satisfies_pipfile_specifier — 2 params, no project.
  • pipenv/routines/update.py:get_modified_pipfile_entries — 2 params (project, pipfile_categories).
  • pipenv/routines/update.py:_prepare_categories — 3 params (categories, dev, packages), no project.
  • pipenv/routines/update.py:_find_additional_categories — 3 params (packages, lockfile, current_categories), no project.
  • pipenv/routines/update.py:_detect_conflicts — 3 params (package_args, reverse_deps, lockfile), no project.
  • pipenv/routines/scan.py:build_safety_check_options — 11 params, no project (it is an arg-builder, not a routine).
  • pipenv/routines/scan.py:build_safety_scan_options — 7 params, no project (arg-builder).
  • pipenv/routines/check.py:build_safety_options — 8 params, no project (arg-builder).
  • pipenv/routines/audit.py:build_audit_options — 14 params, no project (arg-builder).
  • pipenv/routines/scan.py:run_pep508_check, check_pep508_requirements, get_requirements, is_safety_installed, install_safety, run_safety_scan, parse_safety_output, create_temp_requirements_file — internal scan helpers, all ≤3 params or no project.
  • pipenv/routines/check.py:run_pep508_check, check_pep508_requirements, get_requirements, create_temp_requirements, is_safety_installed, install_safety, run_safety_check, parse_safety_output — internal check helpers, all ≤3 params or no project.
  • pipenv/routines/audit.py:is_pip_audit_installed, install_pip_audit — 2 params each.
  • pipenv/routines/requirements.py:_generate_requirements_from_pipfile — internal sibling of generate_requirements; same shape.

The arg-builders (build_safety_*, build_audit_options) are explicitly not routine-context candidates — they translate Python arguments into subprocess CLI flag lists and would not benefit from a shared RoutineContext. They are listed here for completeness.

Cross-cutting observations

  1. pypi_mirror and system are universal. Almost every routine entry point and helper carries pypi_mirror and system (or its alias allow_global) as separate keyword arguments, even though pypi_mirror is also surfaceable as a project setting. Together they account for ~40 rows in the per-routine table. These are the strongest signal that a shared RoutineContext.target_env field group exists.

  2. package_selection shape is duplicated three ways. The trio (packages, editable_packages, categories/pipfile_categories) appears verbatim in do_install, do_update, do_uninstall, upgrade, and handle_new_packages. The same shape with a different name (package_args, pipfile_category, category) recurs in _process_package_args and _resolve_and_update_lockfile. Two near-identical sub-flavours (category vs pipfile_category, categories vs pipfile_categories) co-exist within update.py and call into get_lockfile_section_using_pipfile_category / get_pipfile_category_using_lockfile_section for translation — a RoutineContext could centralise this translation once.

  3. install_policy flags travel as a packet. pre, deploy, skip_lock, ignore_pipfile, lockfile_only always travel together through the install/init/lock chain. clear and lock_only join them in update flows. None of these flags is useful in isolation — they describe a coherent install/lock intent. They are the strongest candidate for a single nested dataclass.

  4. state_flags is small and incoherent. Only 9 rows. The flags in this group (perform_upgrades, has_package_args, explicitly_requested, use_installed, use_lockfile, legacy_mode, scan) describe sub-routine intent rather than user-facing policy and are heterogeneous. This group probably should not be a field of RoutineContext; instead these stay as explicit local parameters to the helpers that need them, or fold into install_policy if they map cleanly. The presence of scan in do_check (a flag that routes to a completely different routine) is a particularly strong code smell.

  5. other is dominated by data-flow plumbing. Most other rows are dicts/queues/strings passed between helpers within a single routine call: lockfile, requested_packages, reverse_deps, procs, sources, old_hash/new_hash. These belong in a per-routine workflow context (a LockOperation / UpgradeOperation object) and should not appear on RoutineContext itself, which is for inputs to a user-facing routine.

Drives T_C.3

This inventory feeds directly into T_C.3's RoutineContext dataclass shape proposal. The observations above suggest a RoutineContext with three nested groups (TargetEnv, InstallPolicy, PackageSelection) plus a list-typed extra_pip_args field; state_flags and other are explicitly left out of the dataclass and remain as call-site arguments to internal helpers. T_C.3 should reference this file for the field-by-field rationale, then this file is deleted as part of T_C.3's commit.