Patchwork [2,of,7] typing: fix forward reference in _Tlocalstr type bound

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 16, 2019, 11:59 a.m.
Message ID <278616fbbe76deecad94.1573905578@mimosa>
Download mbox | patch
Permalink /patch/43296/
State Accepted
Headers show

Comments

Yuya Nishihara - Nov. 16, 2019, 11:59 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1573884641 -32400
#      Sat Nov 16 15:10:41 2019 +0900
# Node ID 278616fbbe76deecad94eb99886b01aed6fe9661
# Parent  788e92d3589b8007e47db7533d01654911335cc5
typing: fix forward reference in _Tlocalstr type bound

AFAIK, a quoted string in type position is translated to its ForwardRef.

  https://github.com/python/typing/issues/34

This fixes the following error:

  File "mercurial/encoding.py", line 38, in <module>: Name 'localstr' is not
  defined [name-error]

Patch

diff --git a/mercurial/encoding.py b/mercurial/encoding.py
--- a/mercurial/encoding.py
+++ b/mercurial/encoding.py
@@ -35,7 +35,7 @@  if not globals():  # hide this from non-
     for t in (Any, Callable, List, Text, Type, Union):
         assert t
 
-    _Tlocalstr = TypeVar('_Tlocalstr', bound=localstr)
+    _Tlocalstr = TypeVar('_Tlocalstr', bound='localstr')
 
 charencode = policy.importmod('charencode')