sloria / environs

simplified environment variable parsing
MIT License
1.22k stars 87 forks source link

amended type definition for ParserMethod #361

Closed pratyush618 closed 3 weeks ago

pratyush618 commented 3 weeks ago

PR: Update ParserMethod Type Alias for More Flexibility

Summary:

This PR updates the ParserMethod type alias to Callable[..., object], which allows it to handle functions with any number of arguments and any return type. This change makes the type more flexible and compatible with a wider range of functions in the codebase.

What Changed:

Why This Change:

The old type alias was too general and not fully defined. By switching to Callable[..., object], we ensure better flexibility for callables, supporting a wider variety of function signatures with different argument types and return types.

Impact:

sloria commented 3 weeks ago

Isn't Callable effectively the same as Callable[..., Any]? Or am I misunderstood?

sloria commented 3 weeks ago

Confirmed. See PEP 484:

As well, a bare Callable in an annotation is equivalent to Callable[..., Any]

So this change shouldn't be necessary. Closing for now

pratyush618 commented 3 weeks ago

have you though of writing environs using pydantic?