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 diagnostic type incompatible #853

Open
AbaoFromCUG opened this issue Aug 17, 2023 · 0 comments
Open

Pyright diagnostic type incompatible #853

AbaoFromCUG opened this issue Aug 17, 2023 · 0 comments

Comments

@AbaoFromCUG
Copy link

@magics_class
class SimpleGPTMagics(Magics):
    api_type = Unicode("openai", help="The type of api that will be used to query the models").tag(config=True)

pyright report

Diagnostics:
1. Argument of type "Literal['openai']" cannot be assigned to parameter "default_value" of type "Sentinel" in function "__init__"
     "Literal['openai']" is incompatible with "Sentinel" [reportGeneralTypeIssues]

class TraitType(BaseDescriptor):
"""A base class for all trait types."""
metadata: t.Dict[str, t.Any] = {}
allow_none = False
read_only = False
info_text = "any value"
default_value: t.Optional[t.Any] = Undefined
def __init__(
self,
default_value=Undefined,
allow_none=False,
read_only=None,
help=None,
config=None,
**kwargs,
):
"""Declare a traitlet.

Undefined = Sentinel(
"Undefined",
"traitlets",
"""
Used in Traitlets to specify that no defaults are set in kwargs
""",
)

Obviously, the argument of TraitType.__init__, default_vaue is infered to Sentinel, what can I do to suppress the diagnostic?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant