Skip to content

def __getattr__(self, attr: str) -> Any: ... is the opposite of the intended behavior. #851

@Ivanca

Description

@Ivanca

What's wrong

When using type stubs for any given python library the idea is that it helps developers avoid common errors when writing code, one of the most common is accessing non-existent properties.

request.foo

But the types for the Request class do the opposite by casting any random attributes as any instead of informing the user about them, specifically they do it at line 84 in request.pyi:

def __getattr__(self, attr: str) -> Any: ...

This is the opposite of what I want in a stubs library, from this or any other one, which is to notify me of non-existent properties, (for example when I make a typo), and that if I ever find myself in the need to use some non-standard attribute for an instace of the Request class I will have to be explicit about it in my code, creating such type myself or by adding # type: ignore next to it, making it completely clear that this is intentional and not accidental.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions