Skip to content

how to declare type for defaultdict(defaultdict) #8839

Discussion options

You must be logged in to vote

On first inspection, this looks like a bug. I'll create an issue from the discussion. In the meantime, you can work around the issue this way:

d: DefaultDict[int, DefaultDict[int, MyClass]] = defaultdict(defaultdict[int, MyClass])

This workaround might not work on older versions of Python where defaultdict was not indexable.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@erictraut
Comment options

@matt-the-midnight-hacker
Comment options

@tofetpuzo
Comment options

Answer selected by matt-the-midnight-hacker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants