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

Wes Turner wes.turner at gmail.com
Tue Mar 22 17:40:39 EDT 2016


On Mar 22, 2016 4:36 PM, "Andrey Vlasovskikh" <andrey.vlasovskikh at gmail.com>
wrote:
>
>
> > 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.

At the least, it would be helpful to either have:

a) a slot / attribute for additional string type metadata (is this an
object subclass that I can just add attrs to)
b) a minimal Text base class

SQL is harder because dialects.

>
> --
> Andrey Vlasovskikh
>
> Web: http://pirx.ru/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160322/6205d264/attachment.html>


More information about the Python-ideas mailing list