Skip to content

Improve docstrings on Module class, workflow strategies, and grouper function #197

@FernandoCelmer

Description

@FernandoCelmer

Description

When a user passes the wrong type to Config, the error message is misleading.

The problem

Config(storage="not a storage")
# NotCallableObject: Problem validating the 'storage' object type; this is not a callable object

The message says "not a callable object" but the real problem is "wrong type". The user thinks: "but I didn't try to call anything?"

The fix

A clearer message:

# Before
"Problem validating the 'storage' object type; this is not a callable object"

# After
"'storage' must be an instance of Storage, got str instead"

How to implement

  1. In dotflow/core/exception.py — update NotCallableObject message or create a new InvalidProviderType exception:

    class InvalidProviderType(DotFlowException):
        def __init__(self, name: str, expected: type, got: type):
            super().__init__(f"'{name}' must be an instance of {expected.__name__}, got {got.__name__} instead")
  2. In dotflow/core/config.py — update the _validate() call:

    if value is not None and not isinstance(value, abc):
        raise InvalidProviderType(name=name, expected=abc, got=type(value))
  3. Small change in 2 files, improves error UX for all users

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or requestgood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions