Skip to content

Type Aliases: Cleanup public versus private documentation annotations. #1

@emcd

Description

@emcd

/claude Please help me cleanup the type aliases in this package as follows:

  • For any type alias, whose name does not end in Argument, check if it has Doc or Fname annotations from the dynadoc package.
    • If yes and it is used as an annotation for the arguments to any public functions (ones whose names do not start with underscore), then create a version whose name is suffixed with Argument. The Doc and Fname annotations should be transferred to the *Argument version from the original version. The *Argument version can reference the original version as its type. Update any arguments to public functions which used the original type alias as their type annotation to use the *Argument version instead.
    • Otherwise, remove the Doc and Fname annotations and leave a Python comment bearing any useful information that they may have conveyed. (To understand what information an Fname may convey, please look at sources/classcore/__/doctab.py.)
  • Look for public functions where arguments have type annotations which are not type aliases.
    • If the same pattern appears as an argument to more than one function, then consider creating an *Argument type alias for it. Generally, we would try to keep such type aliases in the various **/nomina.py files, but if that is not feasible, then place them in the same file where they are used.
    • If a bare type only appears on a single argument to a single function, then make a __.typx.Annotated which encapsulates it and add an appropriate Doc to the best of your understanding.

Note: *Argument type aliases should be kept in a group after other groups of type aliases.

Example

In sources/classcore/nomina.py, we should make DecoratorArgument and transfer the Doc annotation from Decorators to DecoratorArgument:

Decorator: __.typx.TypeAlias = __.typx.Annotated[
    __.cabc.Callable[ [ type[ __.U ] ], type[ __.U ] ],
    __.dynadoc.Doc(
        ''' Class decorator.

            Takes class argument and returns class.
        ''' ),
]

would become:

Decorator: __.typx.TypeAlias = (
    __.cabc.Callable[ [ type[ __.U ] ], type[ __.U ] ] )

and

DecoratorArgument: __.typx.TypeAlias = __.typx.Annotated[
    Decorator,
    __.dynadoc.Doc(
        ''' Class decorator.

            Takes class argument and returns class.
        ''' ),
]

If you find any cases where you are uncertain, please refrain from making a judgment call and flag them in the Github issue comment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions