Skip to content

Pyright diagnostic type incompatible #853

@AbaoFromCUG

Description

@AbaoFromCUG
@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?

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