False positives for @overload signatures

Hi. I’m getting a bunch of false positives for situations like this:

@overload
def foo(self, arg: int) -> str:
    ...

@overload
def foo(self, arg: str) -> int:
    ...

def foo(self, arg: Union[str, int]) -> Union[str, int]:
    # do stuff with self

DeepSource complains that I don’t use self int the first two “functions” (PYL-R0201) and that the “function bodies” are empty (PTC-W0049). I already marked those as false positives with an explanation, but it seemed like a good idea to have this issue documented somewhere so that people can add more info, if they’re having a similar problem.

Cheers!

PS: I would include links to relevant issues, but I don’t have enough reputation or something like that.

Hi @Bibo-Joshi!
Thanks for posting this here.
We just deployed a fix for this one and DeepSource should not complain about this now.

1 Like

Thanks for the quick reply! Should have rerun, then :smiley:

This will be effective for all of your upcoming analyses.
Do let us know here if it is raised again.

Hey. Why this has indeed been resolved for PTC-W0049 and PYL-R0201, I do still get PY-D0003 (Missing module/function docstring) for @overload signatures …

Hi @Bibo-Joshi!
PY-D0003 is a separate checker (for docstrings), which was not checking any decorators but just the presence of docstrings.

We are taking a look at it right now.

Update: @overload is now taken care of while looking for missing-docstring issues.

1 Like

Hi. Don’t know if I reported false positives for this already, but it seems like @overload is not catched, if it’s not the last decorator. E.g. I get false positives for

 @overload
 @staticmethod
 def get_value(obj: OT) -> OT:
    ...

See here.

Hey @Bibo-Joshi : @faisal-deepsource from my team is looking into this and will drop an update.

1 Like

Hey @Bibo-Joshi, Sorry for the delayed response. Can you please rerun the analysis and check whether this issue gets raised? I tried running it internally, and PY-D0003 is suppressed when decorated with @overload from the typing module.

Thanks.

Hi @faisal-deepsource . The issue is still there, see https://deepsource.io/gh/python-telegram-bot/python-telegram-bot/run/a1bc89c4-2cae-4166-8702-20862bfd61d4/python/PY-D0003 first and second entry.

Hey @Bibo-Joshi !
We just pushed another fix for this. Can you check now?

I triggered an analysis on my fork and everything looks good now! :star2:

1 Like

Seems to work fine now :+1: Thanks again for being so quick with the fixes!

1 Like