traitlets icon indicating copy to clipboard operation
traitlets copied to clipboard

Pyright diagnostic type incompatible

Open AbaoFromCUG opened this issue 2 years ago • 0 comments

@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]

https://github.com/ipython/traitlets/blob/05d6ecb6b1f90736cdeacf41c7d5e84b147c1dbd/traitlets/traitlets.py#L479-L497

https://github.com/ipython/traitlets/blob/05d6ecb6b1f90736cdeacf41c7d5e84b147c1dbd/traitlets/traitlets.py#L135-L141

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

AbaoFromCUG avatar Aug 17 '23 06:08 AbaoFromCUG