diff mercurial/encoding.py @ 43793:7b14d649af1b

typing: consolidate "if not globals():" trick Removes redundant inline comments. I think pycompat is good place to host this kind of constants.
author Yuya Nishihara <yuya@tcha.org>
date Tue, 19 Nov 2019 23:49:05 +0900
parents da925257a39e
children be8552f25cab
line wrap: on
line diff
--- a/mercurial/encoding.py	Tue Nov 19 23:19:57 2019 +0900
+++ b/mercurial/encoding.py	Tue Nov 19 23:49:05 2019 +0900
@@ -20,14 +20,11 @@
 
 from .pure import charencode as charencodepure
 
-_TYPE_CHECKING = False
-
-if not globals():  # hide this from non-pytype users
+if pycompat.TYPE_CHECKING:
     from typing import (
         Any,
         Callable,
         List,
-        TYPE_CHECKING as _TYPE_CHECKING,
         Text,
         Type,
         TypeVar,
@@ -124,7 +121,7 @@
         s._utf8 = u
         return s
 
-    if _TYPE_CHECKING:
+    if pycompat.TYPE_CHECKING:
         # pseudo implementation to help pytype see localstr() constructor
         def __init__(self, u, l):
             # type: (bytes, bytes) -> None