DetachHead / basedpyright

pyright fork with various type checking improvements, improved vscode support and pylance features built into the language server
https://docs.basedpyright.com
Other
1.15k stars 21 forks source link

a way to denote that a decorator uses it's function #538

Open KotlinIsland opened 3 months ago

KotlinIsland commented 3 months ago
def register[Fn: Callable[[], None]](fn: Fn) -> Fn:
    register._fn = fn

@register
def _foo():  # unused
    print("hi")

register._fn()

when i have a 'private' function that is decorated with with some decorator that performs some action, either in place or saves it for later, it will get crowdstriked (n.b. we now call false positives "crowdstrikes") with reportUnusedFunction

can an Annotated be introduced:

from basedtyping import Used

def register[Fn: Callable[[], None]](fn: Annotated[Fn, Used]) -> Fn:
    register._fn = fn
KotlinIsland commented 3 months ago

while we are there we can add a Calls, which means that the function will be called in place