sourcery-ai / sourcery

Instant AI code reviews
https://sourcery.ai
MIT License
1.53k stars 66 forks source link

`...` being replaced with `Ellipsis` #273

Closed diceroll123 closed 1 year ago

diceroll123 commented 2 years ago

Checklist

Description

from typing import overload

class Test:
    @overload
    # @staticmethod
    def blah(param: str) -> str:
        # when @staticmethod is commented out, the line below wants to be refactored to Ellipsis
        # which actually causes the overload function to break because Ellipsis is not the same as `...`
        # the refactoring itself is fine, which wants to make the param into `self`, but the `...` -> `Ellipsis` is the bug.
        # this is a weird way to find this bug, I will admit.
        ...

    @overload
    @staticmethod
    def blah(param: int) -> str:
        ...

    @staticmethod
    def blah(param: str | int) -> str:
        return str(param)

Debug Information

IDE Version: Version: 1.71.0 (Universal) Commit: 784b0177c56c607789f9638da7b6bf3230d47a8c Date: 2022-09-01T07:25:38.437Z Electron: 19.0.12 Chromium: 102.0.5005.167 Node.js: 16.14.2 V8: 10.2.154.15-electron.0 OS: Darwin x64 22.1.0 Sandboxed: No

Sourcery Version: v0.12.7

reka commented 2 years ago

Hi @diceroll123 ,

Thanks a lot for reporting this :bug: IMO, it's a rather cool way to find it. :sunglasses:

We'll look into it and let you know when there's a fix.

Hellebore commented 2 years ago

Hi @diceroll123 - I've now added a fix, which will be in the next release.

Hellebore commented 1 year ago

Should now be fixed with 0.12.8