<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div>
      <div style="overflow: auto">
        <div style="max-height: 10000px;">
          <div dir="ltr">mypy currently
            inspects the comment on the line of first assignment for the
            variables to be type hinted.
            <p style="margin-bottom:0cm;line-height:100%">It is logical
              that
              at some time python language will add support to allow
              these type
              hints to move from comments to the code as has happened
              for 'def'
              signatures.
            </p>
            <p style="margin-bottom:0cm;line-height:100%">One logical
              syntax
              would be to move from
            </p>
            <pre>i = 1           # Infer type int for i</pre>
            <p style="margin-bottom:0cm;line-height:100%">
              to</p>
            <pre>i:int = 1       # no comment needed, but does not look attractive


<span style="font-family:arial,sans-serif">The first question that arises is 'is the type inference legal for the additional uses.  Having a 'second use' flagged by warning or error by either an external typechecker or even the language itself could pick up on accidental reuse of a name, but in practice accidentally creating a new variable through a typo can be more common.

In python today the first use is the same as every other, so this change just does not feel comfortable.

The other question is 'what about globals and nonlocals?'.  Currently globals and nonlocals need a 'global' or 'nonlocal' statement to allow assignment, but what if these values are not assigned in scope?

What if we allowed </span>
global i:int</pre>
            <p style="margin-bottom:0cm;line-height:100%">or </p>
            <pre style="margin-bottom:0cm;line-height:100%"><span style="font-family:courier new,monospace">nonlocal i:int</span></pre>
            <p style="margin-bottom:0cm;line-height:100%">and even
            </p>
            <pre style="margin-bottom:0cm;line-height:100%"><span style="font-family:courier new,monospace">local i:int</span></pre>
            <p style="margin-bottom:0cm;line-height:100%"><span
                style="font-family:arial,sans-serif"><font size="2">Permitting
                  a new
                  keyword 'local' to me might bring far more symmetry
                  between different
                  cases.</font></span>
            </p>
            <span style="font-family:arial,sans-serif"><font size="2"></font></span>
            <p style="margin-bottom:0cm;line-height:100%"><span
                style="font-family:arial,sans-serif"><font size="2">It
                  would also allow
                  type hinting to be collected near the function
                  definition and keep
                  the type hinting clear of the main code.</font></span></p>
            <span style="font-family:arial,sans-serif"><font size="2">
              </font></span>
            <p style="margin-bottom:0cm;line-height:100%"><span
                style="font-family:arial,sans-serif"><font size="2">Use
                  of the 'local'
                  keyword in the global namespace could indicate a value
                  not accessible
                  in other namespaces.</font></span></p>
            <span style="font-family:arial,sans-serif"><font size="2">
              </font></span><span style="font-family:arial,sans-serif"><font
                size="2">
              </font></span>
            <p style="margin-bottom:0cm;line-height:100%"><span
                style="font-family:arial,sans-serif"><font size="2">Personally
                  I would
                  like to go even further and allow some syntax to allow
                  (or disable)
                  flagging the use of new variables without type hinting
                  as possible
                  typos</font></span></p>
            <span style="font-family:arial,sans-serif"><font size="2">
              </font></span>
            <p style="margin-bottom:0cm;line-height:100%"><span
                style="font-family:arial,sans-serif"></span><span
                style="font-family:arial,sans-serif"></span><span
                style="font-family:arial,sans-serif"><font size="2">I
                  have a syntax in
                  mind, but the idea is the discussion point, not the
                  specific syntax.</font></span><span
                style="font-family:arial,sans-serif"></span></p>
            <p style="margin-bottom:0cm;line-height:100%"><span
                style="font-family:arial,sans-serif"><font size="2">Possibly
                  what is here already is too much of a change of
                  direction to consider for ideas already in progress?<br>
                </font></span></p>
            <span style="font-family:arial,sans-serif"><font size="2">
              </font></span>
            <p style="margin-bottom:0cm;line-height:100%"><br>
            </p>
          </div>
        </div>
      </div>
    </div>
  </body>
</html>