Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pyright: custom scalar yields "Type of scalar is partially unknown" #3579

Open
tokr-bit opened this issue Jul 25, 2024 · 0 comments
Open

Pyright: custom scalar yields "Type of scalar is partially unknown" #3579

tokr-bit opened this issue Jul 25, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@tokr-bit
Copy link

tokr-bit commented Jul 25, 2024

In our project, we want to introduce an "alias" for a string, which is called CodeInput. Creating a custom scalar as described in the docs yields a pyright error.

Describe the Bug

Creating a custom scalar

CodeInput = strawberry.scalar(
    NewType("CodeInput", str),
    serialize=lambda v: v,
    parse_value=lambda v: v,
)

and checking it via pyright <file> yields:

/home/tobias/repos/demo/backend/demo/graphql/types/codes.py
  /home/tobias/repos/demobackend/demo/graphql/types/codes.py:53:13 - error: Type of "scalar" is partially unknown
    Type of "scalar" is "Overload[(*, name: str | None = None, description: str | None = None, specified_by_url: str | None = None, serialize: (...) -> Unknown = identity, parse_value: ((...) -> Unknown) | None = None, parse_literal: ((...) -> Unknown) | None = None, directives: Iterable[object] = ()) -> ((_T@scalar) -> _T@scalar), (cls: _T@scalar, *, name: str | None = None, description: str | None = None, specified_by_url: str | None = None, serialize: (...) -> Unknown = identity, parse_value: ((...) -> Unknown) | None = None, parse_literal: ((...) -> Unknown) | None = None, directives: Iterable[object] = ()) -> _T@scalar]" (reportUnknownMemberType)
  /home/tobias/repos/demo/backend/demo/graphql/types/codes.py:55:22 - error: Type of parameter "v" is unknown (reportUnknownLambdaType)
  /home/tobias/repos/demo/backend/demo/graphql/types/codes.py:55:25 - error: Return type of lambda is unknown (reportUnknownLambdaType)
  /home/tobias/repos/demo/backend/demo/graphql/types/codes.py:56:24 - error: Type of parameter "v" is unknown (reportUnknownLambdaType)
  /home/tobias/repos/demo/backend/demo/graphql/types/codes.py:56:27 - error: Return type of lambda is unknown (reportUnknownLambdaType)
5 errors, 0 warnings, 0 informations 

System Information

  • Strawberry version (if applicable): 0.235.1

Additional Context

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@tokr-bit tokr-bit added the bug Something isn't working label Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant