Skip to content

Fix NameError: pp not defined at runtime in _operator_states.py - #1709

Closed
keileg with Copilot wants to merge 1 commit into
reference-statesfrom
copilot/fix-pytest-3-13-job-failure
Closed

Fix NameError: pp not defined at runtime in _operator_states.py#1709
keileg with Copilot wants to merge 1 commit into
reference-statesfrom
copilot/fix-pytest-3-13-job-failure

Conversation

Copilot AI commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

import porepy as pp was guarded by TYPE_CHECKING, but pp.GridLikeSequence appeared in __init__ annotations of all three mixin classes (TimeDependentOperator, IterativeOperator, ReferenceOperator). Python evaluates these annotations at class definition time, causing NameError: name 'pp' is not defined on every import porepy — breaking all tests under Python 3.13.

Proposed changes

  • Add from __future__ import annotations to _operator_states.py to defer annotation evaluation, keeping pp safely behind TYPE_CHECKING.

Types of changes

  • Bugfix (non-breaking change which fixes an issue).

Checklist

  • The documentation is up-to-date.
  • Static typing is included in the update.
  • This PR does not duplicate existing functionality.
  • The update is covered by the test suite (including tests added in the PR).
  • If new skipped tests have been introduced in this PR, pytest was run with the --run-skipped flag.

Copilot AI changed the title Fix NameError: name 'pp' is not defined in _operator_states.py Fix NameError: pp not defined at runtime in _operator_states.py Jun 29, 2026
Copilot AI requested a review from keileg June 29, 2026 08:40
@keileg

keileg commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Included directly in #1696

@keileg keileg closed this Jun 30, 2026
@keileg
keileg deleted the copilot/fix-pytest-3-13-job-failure branch September 3, 2026 06:20
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