[Python-ideas] Type hints for text/binary data in Python 2+3 code

Andrey Vlasovskikh andrey.vlasovskikh at gmail.com
Tue Mar 22 17:36:40 EDT 2016


> 2016-03-19, в 5:12, Wes Turner <wes.turner at gmail.com> написал(а):
> 
> This sounds like a more correct approach, thanks.
> 
> Looking at MarkupSafe (and, now, f-strings), would/will it be possible to use Typing.Text as a base class for even-more abstract string types ("strypes") e.g. XML, XHTML, HTML4, HTML5, HTML5.1, SQL? There are implicit casts and contextual adaptations/transformations (which MarkupSafe specs a bit). (I've no real code here, just a general idea that we're not tracking enough string metadata to be safe here)

I believe having separate string types for XML or SQL content is out of the scope of this proposal.

In PyCharm we already treat the contents of string literals with SQL as a separate SQL syntax tree and we understand basic string operations like concatenation or formatting. Going beyond that with the help of XML/SQL/etc. string types is possible, but I doubt we need a standard for that.

-- 
Andrey Vlasovskikh

Web: http://pirx.ru/



More information about the Python-ideas mailing list