Skip to content

optional private list parameters shows warning #3917

Open
@Speedy1991

Description

@Speedy1991

This shows a warning on _panels in pycharm:

import strawberry


@strawberry.type
class PanelType:
    id: strawberry.ID


@strawberry.type
class PageType:
    _panels: strawberry.Private[list[PanelType] | None] = None

    @strawberry.field
    def panels(self, info: strawberry.Info) -> list[PanelType]:
        return self._panels


@strawberry.type
class Query:
    @strawberry.field
    def hello(self, info: strawberry.Info) -> PageType:
        return PageType(_panels=[PanelType(id=strawberry.ID('a'))])

Image

Also confirmed with pyright

error: Type "Private[list[PanelType] | None]" is not assignable to return type "list[PanelType]"
    Type "Private[list[PanelType] | None]" is not assignable to type "list[PanelType]"
      "None" is not assignable to "list[PanelType]" (reportReturnType)
1 error, 0 warnings, 0 informations 

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