Skip to content

Type annotations: I think werkzeug.wrappers.Request.json can never be None #3067

@oprypin

Description

@oprypin

I am talking about this property: https://werkzeug.palletsprojects.com/en/stable/wrappers/#werkzeug.wrappers.Request.json

@property
def json(self) -> t.Any | None:

I think it can never actually return None, because it calls get_json() with all defaults, which is silent=False, making it never return None and raise in those cases instead.

This issue is still current in the latest release and latest unreleased code.

I am using Pyright, and it complains about usages such as flask.request.json["foo"].

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions