Skip to content

questions about CheckedDict and unknown types #71

Description

@bennn

IIUC (based on issue 59), types like CheckedDict[str, Set[str]] where SP doesn't understand part of the type should:

  1. be allowed, and
  2. turn into CheckedDict[str, object]

But neither seems to work. (I'm running SP commit 1b01cd8.)

First, this type doesn't work except in a constructor call. Other type annotations give an error:

from __static__ import CheckedDict
from typing import Set

def f(dd: CheckedDict[int, Set[str]]):
  return

#     def f(dd: CheckedDict[int, Set[str]]):
# TypeError: expected type or Optional[T] for generic argument

Second, the constructor call gives a chkdict[str, dynamic] instead of replacing the unknown type with object:

from __static__ import CheckedDict
from typing import Set

d0: CheckedDict[str, dynamic] = CheckedDict[str, Set[str]]({})
# OK
d1: CheckedDict[str, object] = CheckedDict[str, Set[str]]({})
# compiler.errors.TypedSyntaxError: type mismatch: chkdict[str, dynamic] cannot be assigned to chkdict[str, object]

Are these problems?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    sp-uxstatic python user experience issuesstaticpythonstatic python issues

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions