Skip to content

chore: generate grafeas - #17307

Merged
parthea merged 3 commits into
mainfrom
generate-grafeas-20260529
May 29, 2026
Merged

chore: generate grafeas#17307
parthea merged 3 commits into
mainfrom
generate-grafeas-20260529

Conversation

@parthea

@parthea parthea commented May 29, 2026

Copy link
Copy Markdown
Contributor

Towards #17305

See follow up issue #17311

@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 minimum grpcio dependency version to 1.59.0, adjusts Nox configuration to dynamically resolve constraints files, and refactors unit tests to parameterize request types. Feedback on these changes highlights a potential issue in noxfile.py where dynamic path resolution using ALL_PYTHON[0] might point to a non-existent file if the corresponding constraints file is missing. Additionally, in test_grafeas.py, passing instantiated objects like {} in @pytest.mark.parametrize introduces shared mutable state across tests and makes the parameter name request_type misleading; it is recommended to pass types and instantiate them within the tests instead.

Comment on lines +50 to +55
if (CURRENT_DIRECTORY / "testing").exists():
LOWER_BOUND_CONSTRAINTS_FILE = (
CURRENT_DIRECTORY / "testing" / f"constraints-{ALL_PYTHON[0]}.txt"
)
else:
LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt"

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.

medium

If ALL_PYTHON[0] (the minimum Python version) does not match the version in the constraints file name (e.g., if ALL_PYTHON[0] is "3.7" but only constraints-3.10.txt exists), this dynamic path resolution will point to a non-existent file and cause Nox sessions to fail.

Consider adding a fallback check to ensure the file exists, or dynamically locate the constraints file using a glob pattern.

Comment on lines 118 to 124
@pytest.mark.parametrize(
"request_type",
[
grafeas.GetOccurrenceRequest,
dict,
grafeas.GetOccurrenceRequest(),
{},
],
)

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.

medium

There are two issues with this parameterization:

  1. Shared Mutable State: Passing {} as a parameter in @pytest.mark.parametrize means the same dictionary instance is shared across all test runs. If any test or underlying client code mutates the request, it will pollute the state for subsequent tests, potentially causing flaky tests.
  2. Misleading Naming: The parameter is named request_type, but it now receives an instance (e.g., GetOccurrenceRequest() or {}) instead of a type/class.

It is safer and cleaner to pass the classes/types (or callables) and instantiate them inside the test (e.g., request = request_type()), which guarantees a fresh, independent instance for every test execution.

Suggested change
@pytest.mark.parametrize(
"request_type",
[
grafeas.GetOccurrenceRequest,
dict,
grafeas.GetOccurrenceRequest(),
{},
],
)
@pytest.mark.parametrize(
"request_type",
[
grafeas.GetOccurrenceRequest,
dict,
],
)

@parthea
parthea marked this pull request as ready for review May 29, 2026 14:57
@parthea
parthea requested a review from a team as a code owner May 29, 2026 14:57
@parthea
parthea merged commit 2024224 into main May 29, 2026
31 checks passed
@parthea
parthea deleted the generate-grafeas-20260529 branch May 29, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants