Hi all

I'm guessing the answer to my question in the subject line is "yes", but I'm hoping its "not necessarily".

I'm working on stubs for Pandas. Pandas Series have a bunch of methods for which there is an "in place" argument. If True, the method will return None; if False, it will return a new DataFrame.

The way I thought of trying to handle this is by doing something like this:

@overload
def replace(self, to_replace: Optional[Any] = ..., value: Optional[Any] = ..., inplace: Literal[True], limit: Optional[int] = ..., regex: _Regex = ..., method: _str = ...) -> None: ...
@overload
def replace(self, to_replace: Optional[Any] = ..., value: Optional[Any] = ..., inplace: Optional[Literal[False]] = ..., limit: Optional[int] = ..., regex: _Regex = ..., method: _str = ...) -> DataFrame: ..

The problem is that in the first case I am making the optional argument mandatory, and it lies in the middle of other optional arguments. I don't want to move it positionally because there is plenty of existing code out there that would then break.

My guess is that this is not okay, but is there an alternative solution?

Thanks
Graham