Skip to content

Add Type Hints to FlaskView Class Properties that are Typically Strings but Initialized as None #203

@dcloutman

Description

@dcloutman

I have noticed that when I override the value of a class property that is defined in FlaskView, my IDE (VSCode) complains about incomparable types. Specifically, this occurs when I assign a string value to FlaskView.base_route, and I presume the same issue would persist if I assigned a value similarly to FlaskView.route_prefix. I tried hacking the core library a bit, and adding the type hint "str|None" seemed to make the IDE complaint go away. Without the explicit type hint, the IDE assumes that the property's inferred type is None, which is not the case in practical usage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions