Skip to content

docs(dlp): fix argument names in list_dlp_jobs docstring - #14787

Open
mmporong wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
mmporong:dlp-list-jobs-docstring-args
Open

mmporong wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
mmporong:dlp-list-jobs-docstring-args

Conversation

@mmporong

Copy link
Copy Markdown

Description

No linked issue: this is a docstring-only fix in one sample.

The Args: section of list_dlp_jobs in dlp/snippets/Jobs/list_jobs.py documents filter and type, but the function signature is:

def list_dlp_jobs(
    project: str, filter_string: Optional[str] = None, job_type: Optional[str] = None
) -> None:

Calling the sample with the documented names fails before any API call:

>>> list_dlp_jobs("my-project", filter="state=DONE")
TypeError: list_dlp_jobs() got an unexpected keyword argument 'filter'
>>> list_dlp_jobs("my-project", type="INSPECT_JOB")
TypeError: list_dlp_jobs() got an unexpected keyword argument 'type'

Changes:

  • Rename the two entries to filter_string and job_type. The __main__ block already passes filter_string=args.filter, job_type=args.type, so the CLI flags stay as they are.
  • In the job_type entry, replace "Defaults to 'INSPECT'" with "If not set, the API defaults to INSPECT_JOB". The parameter default is None, and 'INSPECT' is not a key of job_type_to_int, so passing it raises KeyError. The API default comes from ListDlpJobsRequest.type_ ("Defaults to DlpJobType.INSPECT"), whose enum member is INSPECT_JOB. The CLI help in the same file already says API defaults to "INSPECT".

Checked in a python:3.10-slim container with dlp/snippets/requirements.txt installed:

  • Every name in the Args: section now binds with inspect.signature(list_dlp_jobs).bind(...) (before: filter and type raised TypeError).
  • flake8 with the FLAKE8_COMMON_ARGS from noxfile-template.py on list_jobs.py: no findings.

Checklist

Testing

  • I have tested this change on a live environment and verified it works as intended.

Not run against a live project: only the docstring changed, no code path changed.

Compliance & Style


Post-Approval Actions

  • Please merge this PR for me once it is approved

The Args section documented `filter` and `type`, but the function
parameters are `filter_string` and `job_type`. Passing the documented
names as keyword arguments raises TypeError.

Also clarify that INSPECT_JOB is the API default when `job_type` is not
set; 'INSPECT' is not one of the accepted values.
@mmporong
mmporong requested review from a team as code owners November 12, 2026 04:05
@product-auto-label product-auto-label Bot added api: dlp Issues related to the Sensitive Data Protection API. samples Issues that are directly related to samples. labels Nov 12, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the docstring of the list_dlp_jobs function in dlp/snippets/Jobs/list_jobs.py to rename the filter parameter to filter_string and the type parameter to job_type, aligning the documentation with the correct parameter names and clarifying the default job type behavior. No review comments were provided, and there is no additional feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: dlp Issues related to the Sensitive Data Protection API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants