Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redesign Render Arguments & Data Namespace APIs #101

Merged
merged 10 commits into from
Nov 24, 2023
Merged

Conversation

AnonymouX47
Copy link
Owner

@AnonymouX47 AnonymouX47 commented Nov 22, 2023

  • Fixes render argument/data namespace class names.

  • Redesigns namespaces classes.

  • Delegates association of namespace classes to their metaclasses instead of RenderableMeta.

  • Simplifies the collection of render argument/data namespaces of parent render classes in RenderableMeta.

  • Drops the use of inner class definitions.

    • Renderable._Data_ -> RenderableData.
    • RenderArgs.Namespace -> ArgsNamespace.
    • RenderData.Namespace -> DataNamespace.

    In .renderable._types:

    • RenderArgsData._NamespaceMeta -> ArgsDataNamespaceMeta.
    • RenderArgsData.Namespace -> ArgsDataNamespace.
    • RenderArgs._NamespaceMeta -> ArgsNamespaceMeta.
  • Adds .renderable._types.DataNamespaceMeta.

  • Updates documentation for render argument and data namespaces.

  • Updates tests related to render argument and data namespaces.

  • Updates definitions of render argument and data namespaces across the tests.


Required for the advancement of #100.

From a dynamic typing perspective, both the current and new APIs are equally good but the current will not work with static typing.

The new API happens to have a couple minor downsides though:

  1. If a RenderArgs(render_cls) is created before an argument namespace class is associated with render_cls, that RenderArgs instance will lack a namespace for render_cls, unlike those created afterwards.
  2. If render_cls is subclassed before an argument namespace class is associated with render_cls, every RenderArgs instance associated with that subclass will lack a namespace for render_cls.

The same applies to render data... but looking on the bright side, this typically shouldn't occur and there's an admonition in the docs concerning this.

- Add: Export some new classes from `.renderable`:
  - `ArgsNamespace`
  - `DataNamespace`
  - `RenderableData`
- Change: `Renderable._Data_` -> `RenderableData`.
- Change: Simplify the collection of render argument/data namespaces
  of parent render classes in `RenderableMeta`.
- Change: Delegate association of render args/data namespace classes
  to the namespace metaclasses; No longer handled by `RenderableMeta`.

In `.renderable._types`:

- Add: Export `ArgsNamespace` and `DataNamespace`.
- Add: `DataNamespaceMeta`.
- Change: `RenderArgsData._NamespaceMeta` -> `ArgsDataNamespaceMeta`.
- Change: `RenderArgsData.Namespace` -> `ArgsDataNamespace`.
- Change: `RenderArg._NamespaceMeta` -> `ArgsNamespaceMeta`.
- Change: `RenderArgs.Namespace` -> `ArgsNamespace`.
- Change: `RenderData.Namespace` -> `DataNamespace`.
- Fix: Rename local variable variable *name* -> *field_name* in
  `ArgsDataNamespaceMeta.__new__()`.
- Change: Update docs related to render argument and data namespaces.
- Change: Update render args/data namespace class definitions.
- Change: Update tests for render args/data namespace classes.
- Change: Update render args/data namespace class definitions.
- Change: Update render args/data namespace-related tests for
  `RenderableMeta`.
- Change: Update render args/data namespace class definitions.
@AnonymouX47 AnonymouX47 added fix Fixes a bug improvement Implementation of improvement to an existing feature renderable Related to the Renderable API labels Nov 22, 2023
@AnonymouX47 AnonymouX47 added this to the 0.8.0 milestone Nov 22, 2023
- Change: "*defines* render args/data" -> "*has* render args/data".
- Change: Update warnings about render argument/data field number and
  order.
- Change: Use namespace class name instead of that of the associated
  render class in the error message when too many field values are
  given.

  The namespace class is actually the one that defines the fields.

- Change: Update the affected test.
@AnonymouX47 AnonymouX47 merged commit 00ade57 into main Nov 24, 2023
16 checks passed
@AnonymouX47 AnonymouX47 deleted the renderable-redesign branch November 24, 2023 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Fixes a bug improvement Implementation of improvement to an existing feature renderable Related to the Renderable API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant