You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a dummy object to designate "uninitialized" networks (fixes#511) (#525)
Add an _UnitializedNetwork class and a singleton
_UNINITIALIZED_NETWORK instance. It can replace the dummy "None"
value for attribute initializations, which can then be properly typed
as Network to avoid static type checking errors.
This has the benefit of not needing `self.network is not None` checks
at run-time wherever a method or attribute access is used, but still
satisfies static type checking. When hitting such a code path at
run-time, of course it will lead to an exception because the
attributes required in the Network methods are not set. But that is a
case of wrong API usage (accessing a network without associating it
first), which a static checker cannot detect reliably. The dummy
class provides a descriptive exception message when any attribute is
accessed on it.
0 commit comments