Skip to content

Conversation

@leo-collins
Copy link
Contributor

@leo-collins leo-collins commented Nov 13, 2025

Explicit imports in firedrake/__init__.py. Fixes namespace leakage problem #4696.

Things that are no longer in the firedrake namespace (not exhaustive):

  • np
  • stop_annotating
  • ufl
  • PETSc

Copy link
Contributor

@connorjward connorjward left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks for taking this on.

It seems like a fair number of tests are still failing. Also when we merge this we should announce it.

# from firedrake._deprecation import output
# sys.modules["firedrake.output"] = output
from firedrake.output import *
from firedrake.output import * # noqa: F401
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could probably remove firedrake.output and firedrake.plot from the global namespace now? It was moved to firedrake.pyplot around two years ago: #3117. Also #3324

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah good idea

import sys
sys.modules["firedrake.plot"] = plot
from firedrake.plot import *
from firedrake.plot import * # noqa: F401
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto

real
)
from firedrake.cython import dmcommon
from firedrake import mesh
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh amazing. I always hated this.

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.

3 participants