Skip to content

Add test coverage for walrus with allow-redefinition#21605

Open
popsiclelmlm wants to merge 1 commit into
python:masterfrom
popsiclelmlm:codex/mypy-walrus-redefinition-tests
Open

Add test coverage for walrus with allow-redefinition#21605
popsiclelmlm wants to merge 1 commit into
python:masterfrom
popsiclelmlm:codex/mypy-walrus-redefinition-tests

Conversation

@popsiclelmlm

Copy link
Copy Markdown

Summary

  • Add regression coverage for assignment expressions used with --allow-redefinition.
  • Cover variables introduced by walrus expressions and then redefined to a different type.

Reproduction

Root cause

  • Existing tests covered assignment-expression branch merging, but did not cover subsequent redefinition of walrus-introduced variables under --allow-redefinition.

Changes

  • Extended testNewRedefineAssignmentExpression in test-data/unit/check-redefine2.test with two focused cases.

Tests

  • .venv/bin/python -m pytest -n0 -q mypy/test/testcheck.py::TypeCheckSuite::check-redefine2.test -k NewRedefineAssignmentExpression
  • .venv/bin/python -m pytest -n0 -q mypy/test/testcheck.py::TypeCheckSuite::check-redefine2.test
  • .venv/bin/pre-commit run --files test-data/unit/check-redefine2.test
  • git diff --check

Screenshots/Logs

  • Not applicable; test-only change.

Disclosure

  • I used an LLM assistant while preparing this test-only change and reviewed the diff and test results before submission.

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.

1 participant