Skip to content

Conversation

@rchen152
Copy link
Collaborator

I played around with this in a 2.7 interpreter, and as far as I
can tell, the template and mapping keys can be str or
unicode, the return type is str if all of the mapping values are
str, and the return type is unicode if at least one mapping value
is unicode.

I played around with this in a 2.7 interpreter, and as far as I
can tell, the template and mapping keys can be str or
unicode, the return type is str if all of the mapping values are
str, and the return type is unicode if at least one mappng value
is unicode.
Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. One optional change, since you are currently editing this: Template is actually an old-style class, so it shouldn't derive from object.

@rchen152
Copy link
Collaborator Author

Fixed!

@srittau srittau merged commit e541cdd into master Mar 16, 2019
@srittau srittau deleted the string branch March 16, 2019 21:12
@msullivan
Copy link
Contributor

This seems to break substitutions using just a Dict[str, str], since mapping is not covariant in its key type.

template.py:5: error: Argument 1 to "substitute" of "Template" has incompatible type "Dict[str, str]"; expected "Mapping[unicode, str]"

@JelleZijlstra
Copy link
Member

Makes sense. We should probably use Union[Mapping[str, ...], Mapping[Text, ...]]

@rchen152
Copy link
Collaborator Author

Sorry about that! I sent #2888 to fix the type of mapping.

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

Successfully merging this pull request may close these issues.

5 participants