From d5192113eef852f1324b664e097b1520ad8e3e98 Mon Sep 17 00:00:00 2001 From: whitequark Date: Mon, 21 Oct 2019 10:39:21 +0000 Subject: [PATCH] Explicitly restrict prelude imports. It turns out that while Python does not import _private identifiers when using * imports, it does nevertheless import all submodules. Avoid polluting the namespace in the prelude by explicitly listing all exported identifiers. --- nmigen/__init__.py | 14 ++++++++++++++ nmigen/hdl/__init__.py | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/nmigen/__init__.py b/nmigen/__init__.py index e90da10..bb0c239 100644 --- a/nmigen/__init__.py +++ b/nmigen/__init__.py @@ -4,4 +4,18 @@ try: except pkg_resources.DistributionNotFound: pass + from .hdl import * + + +__all__ = [ + "Shape", "unsigned", "signed", + "Value", "Const", "C", "Mux", "Cat", "Repl", "Array", "Signal", "ClockSignal", "ResetSignal", + "Module", + "ClockDomain", + "Elaboratable", "Fragment", "Instance", + "Memory", + "Record", + "DomainRenamer", "ResetInserter", "EnableInserter", + "CEInserter", # TODO(nmigen-0.2): remove this +] diff --git a/nmigen/hdl/__init__.py b/nmigen/hdl/__init__.py index 355b9f8..9b53c87 100644 --- a/nmigen/hdl/__init__.py +++ b/nmigen/hdl/__init__.py @@ -6,4 +6,17 @@ from .ir import Elaboratable, Fragment, Instance from .mem import Memory from .rec import Record from .xfrm import DomainRenamer, ResetInserter, EnableInserter, \ - CEInserter # deprecated + CEInserter # TODO(nmigen-0.2): remove this + + +__all__ = [ + "Shape", "unsigned", "signed", + "Value", "Const", "C", "Mux", "Cat", "Repl", "Array", "Signal", "ClockSignal", "ResetSignal", + "Module", + "ClockDomain", + "Elaboratable", "Fragment", "Instance", + "Memory", + "Record", + "DomainRenamer", "ResetInserter", "EnableInserter", + "CEInserter", # TODO(nmigen-0.2): remove this +] -- 2.30.2