Skip to content

Warn user to add @early_return when use unwrap_or_return #69

@acostapazo

Description

@acostapazo

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I already read and followed all the documentation and didn't find an answer.

Description & Wanted Solution

The documentation currently provides guidance on using the unwrap_or_return option to minimize visual noise, as outlined here: Meiga Documentation - unwrap_or_return.

However, for users who may not be familiar with the meiga package, there's a potential oversight – the need to decorate the function with @early_return might be overlooked.

Suggestion:
To enhance user experience, it would be beneficial to include an alert or warning, explicitly prompting users to add the @early_return decorator when utilizing the unwrap_or_return option. This addition would serve as a helpful reminder and prevent potential oversight for those less familiar with the package.

Wanted Code

# @early_return # WHEN YOU FORGOT TO ADD THIS
def handling_result(key: str) -> Result:
    user_info = {"first_name": "Rosalia", "last_name": "De Castro", "age": 60}
    first_name = string_from_key(dictionary=user_info, key=key).unwrap_or_return()
    # Do whatever with the name
    name = first_name.lower()
    return Result(success=name)

Alternatives

No response

Additional Context

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions