Hide classes from the module which can't be instantiated #189

Closed
opened 2026-01-06 02:49:11 +00:00 by john · 0 comments
Owner

mcrfpy.Window, mcrfpy.Keyboard are classes which really shouldn't be instantiated.

These classes should not be exported by mcrfpy:

  • EntityCollection
  • UICollection
  • UICollectionIter
  • UIEntityCollectionIter (the inconsistency from EntityCollection bothers me here, too)
  • GridPoint
  • GridPointState

I see mcrfpy.default_fov but not mcrfpy.default_transition - yet default_transition can be retrieved - is some getattr black magic occurring? The defaults should be visible.

Theoretically, curious users might still be able to get a reference to these class objects by calling type(someresult), which is fine; I just don't want to clutter the namespace with objects that users really don't need direct access to.

I'm deliberately excluding mcrfpy.Drawable from the exclude list. Users have a use for it: isinstance(widget, mcrfpy.Drawble).

  • For consistency, these classes should all give similar errors that indicate that users should not be trying to create new instances directly. (mcrfpy.Keyboard is instantiable)
  • if #186 is already done, hide the mcrfpy.Mouse class too.
`mcrfpy.Window`, `mcrfpy.Keyboard` are classes which really shouldn't be instantiated. These classes should not be exported by `mcrfpy`: * `EntityCollection` * `UICollection` * `UICollectionIter` * `UIEntityCollectionIter` (the inconsistency from `EntityCollection` bothers me here, too) * `GridPoint` * `GridPointState` I see `mcrfpy.default_fov` but not `mcrfpy.default_transition` - yet `default_transition` can be retrieved - is some `getattr` black magic occurring? The defaults *should* be visible. Theoretically, curious users might still be able to get a reference to these class objects by calling `type(someresult)`, which is fine; I just don't want to clutter the namespace with objects that users really don't need direct access to. I'm deliberately excluding `mcrfpy.Drawable` from the exclude list. Users have a use for it: `isinstance(widget, mcrfpy.Drawble)`. * For consistency, these classes should all give similar errors that indicate that users should not be trying to create new instances directly. (`mcrfpy.Keyboard` is instantiable) * if #186 is already done, hide the `mcrfpy.Mouse` class too.
john closed this issue 2026-01-06 09:41:55 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
john/McRogueFace#189
No description provided.