Re: [Feature request] Template language type annotations (#27703)

2017-01-10 Thread Martin Owens


On Monday, January 9, 2017 at 2:43:00 PM UTC-5, Дмитрий Симонов wrote:
>
> Ok. Here is my example with multiline annotations.
>
> https://github.com/a1fred/django-template-type-annotations
>
> What do you think?
>

It should probably avoid parsing of the main body, I don't believe that to 
be canonical with the rest of django's tags.

It might be better to parse each pair of variables from the {% var %} tag 
itself. Just allow that tag to take more than one pair and you should have 
all the support for single and multiple declarations.

The other issue I have is that the tag doesn't effect the output the 
template produces, so it's placement in templates will complicate the 
formatting for non-coding contributors. This might be worth it, but I can 
see the benefit of keeping these check lists outside of the template file 
itself too. Having a test suite pick up these issues is my preferred 
pattern, but anyway you develop it you'll have a very small amount of use 
from most projects.

Best Regards, Martin Owens
Inkscape Website Admin

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/a06029e0-ceb4-4b7c-bd63-6acbaa406fd1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Feature request] Template language type annotations (#27703)

2017-01-09 Thread Дмитрий Симонов
Ok. Here is my example with multiline annotations.

https://github.com/a1fred/django-template-type-annotations

What do you think?

2017-01-09 19:03 GMT+03:00 Adam Johnson :

> I think a third party implementation could be done first for the separate
> tag. I also think you'd learn more and iterate faster by building some
> tooling on top of the tags whilst a third party app before merging with
> core was considered. One idea that springs to mind is allowing multiple
> type declarations in the same tag rather than requiring *"{% var " *written
> multiple times.
>
> On 9 January 2017 at 15:38, Дмитрий Симонов  wrote:
>
>> Hi guys.
>>
>> Lets discuss about this ticket
>> 
>>
>> I think we need create new tag in template language to annotate context
>> variable types. Something like PEP 484
>>  but on templates.
>> As in pep 484 main goal is provide easier static analysis, potential
>> error checking and improve IDEs and editors support.
>> We can do this with new small tag. Something like:
>>
>> @register.simpletag(name='var')
>> def type_hint(variable,variable_type_string: str) -> None:
>> pass
>>
>> Then we can annotate variable in template:
>>
>> {% var request 'django.http.HttpResponse' %} %}
>>
>> or
>>
>> {% var is_paginated 'bool' %}
>>
>> or
>>
>> {% var user_or_none 'typing.Union[None, django.contrib.auth.models.User]'
>> %}
>>
>> maybe
>>
>> {% var user_or_none 'typing.Union[None, django.conf.settings.AUTH_USER
>> _MODEL]' %}
>>
>>
>> Main idea is add this template to django default tags, not third part
>> application.
>> Then IDE, editor plugins, and analysis tools can build support, based on
>> this.
>>
>> Similar links:
>> https://blog.jetbrains.com/idea/2009/08/enabling-implicit-
>> context-variables-resolution-in-template-files/
>> https://weblogs.asp.net/scottgu/asp-net-mvc-3-new-model-
>> directive-support-in-razor
>>
>> English is not my mother tongue; please excuse any errors on my part.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django developers (Contributions to Django itself)" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-developers+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-developers@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-developers.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-developers/53df8783-7234-405e-a325-a8bed448cd35%
>> 40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Adam
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to django-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-developers/CAMyDDM2jxHm-PhD4VUQt%3DUbWeHV%3D51zKW%3Das9Kzc-
> Bqg4sCoZg%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAGWEbUi8N4MgVYrJdETL_pBTaphE0TLee_QmO8NrD9yzutOOnw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Feature request] Template language type annotations (#27703)

2017-01-09 Thread Adam Johnson
I think a third party implementation could be done first for the separate
tag. I also think you'd learn more and iterate faster by building some
tooling on top of the tags whilst a third party app before merging with
core was considered. One idea that springs to mind is allowing multiple
type declarations in the same tag rather than requiring *"{% var " *written
multiple times.

On 9 January 2017 at 15:38, Дмитрий Симонов  wrote:

> Hi guys.
>
> Lets discuss about this ticket
> 
>
> I think we need create new tag in template language to annotate context
> variable types. Something like PEP 484
>  but on templates.
> As in pep 484 main goal is provide easier static analysis, potential error
> checking and improve IDEs and editors support.
> We can do this with new small tag. Something like:
>
> @register.simpletag(name='var')
> def type_hint(variable,variable_type_string: str) -> None:
> pass
>
> Then we can annotate variable in template:
>
> {% var request 'django.http.HttpResponse' %} %}
>
> or
>
> {% var is_paginated 'bool' %}
>
> or
>
> {% var user_or_none 'typing.Union[None, django.contrib.auth.models.User]'
> %}
>
> maybe
>
> {% var user_or_none 'typing.Union[None, django.conf.settings.AUTH_
> USER_MODEL]' %}
>
>
> Main idea is add this template to django default tags, not third part
> application.
> Then IDE, editor plugins, and analysis tools can build support, based on
> this.
>
> Similar links:
> https://blog.jetbrains.com/idea/2009/08/enabling-
> implicit-context-variables-resolution-in-template-files/
> https://weblogs.asp.net/scottgu/asp-net-mvc-3-new-
> model-directive-support-in-razor
>
> English is not my mother tongue; please excuse any errors on my part.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to django-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-developers/53df8783-7234-405e-a325-
> a8bed448cd35%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Adam

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAMyDDM2jxHm-PhD4VUQt%3DUbWeHV%3D51zKW%3Das9Kzc-Bqg4sCoZg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.