The majority of Haiku modules are implemented in terms of Haiku public API.
This was previously done via an ad-hoc types.ModuleTypes object mirroring
the structure of the public API. For example,
hk = types.ModuleType("haiku")
hk.Module = module.Module
That worked okay at runtime, but was opaque to Python tooling, which cannot
reason about modules defined in such way.
This change implements an alternative approach, where hk is a class. Although
not particularly pretty, the new version is easy to reason about for both
humans and tooling.
Changed how hk is defined in _src submodules
The majority of Haiku modules are implemented in terms of Haiku public API. This was previously done via an ad-hoc types.ModuleTypes object mirroring the structure of the public API. For example,
hk = types.ModuleType("haiku") hk.Module = module.Module
That worked okay at runtime, but was opaque to Python tooling, which cannot reason about modules defined in such way.
This change implements an alternative approach, where hk is a class. Although not particularly pretty, the new version is easy to reason about for both humans and tooling.