Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn about overloads that make other overloads useless #246

Closed
twoertwein opened this issue Jul 12, 2022 · 2 comments
Closed

Warn about overloads that make other overloads useless #246

twoertwein opened this issue Jul 12, 2022 · 2 comments

Comments

@twoertwein
Copy link
Contributor

The same example as in #245 but with one overload that I omitted in #245 (the last overload):

    @overload
    def agg(self, arg: str, *args, **kwargs) -> DataFrame: ...
    @overload
    def agg(self, arg: Dict, *args, **kwargs) -> DataFrame: ...
    @overload
    def agg(self, arg: FuncType, *args, **kwargs) -> DataFrame: ...
    @overload
    def agg(self, *args, **kwargs) -> DataFrame: ...

While the last overload allows specifying no positional arguments, it also makes the other overloads obsolete: the first positional parameter (if present) can be of any type, not only of str | Dict | FuncType.

@JelleZijlstra
Copy link
Collaborator

This feels like it might be a better fit for a type checker, not a linter, since it requires a fairly sophisticated understanding of overloads.

@AlexWaygood
Copy link
Collaborator

I agree with @JelleZijlstra: this one feels out of scope. You're getting into the question of "Is parameter specification X a subtype of parameter specification Y?", and that feels like something a type checker is far better equipped to answer than a humble linter :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants