Skip to content

Method name shadows outer class used in the method signature #3581

@Andrej730

Description

@Andrej730

Summary

Hi! Migrating from pyright to ty, stumbling upon function name shadowing the type available in the outer scope, see below - it results in an error and function returns Unknown instead of declaration.

class declaration:
    ...

class A:
    # Function `declaration` is not valid in a return type annotation (invalid-type-form) [Ln 5, Col 30]
    def declaration(self) -> declaration: ...


# `a` is `Unknown`
a = A().declaration()

Playground
Code sample in pyright playground

Version

0.0.40

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions