From 5dcb03b64dac3b94122da63a6a623c4b9da7b4a8 Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Mon, 20 May 2019 16:13:07 -0400 Subject: [PATCH] Move `isidentifier` to hy.lex --- hy/_compat.py | 10 +--------- hy/lex/__init__.py | 10 +++++++++- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/hy/_compat.py b/hy/_compat.py index 57a67dd..4b7d471 100644 --- a/hy/_compat.py +++ b/hy/_compat.py @@ -2,7 +2,7 @@ # This file is part of Hy, which is free software licensed under the Expat # license. See the LICENSE. -import sys, keyword +import sys PY3 = sys.version_info[0] >= 3 PY36 = sys.version_info >= (3, 6) @@ -15,11 +15,3 @@ def reraise(exc_type, value, traceback=None): raise value.with_traceback(traceback) finally: traceback = None - - -def isidentifier(x): - if x in ('True', 'False', 'None'): - return True - if keyword.iskeyword(x): - return False - return x.isidentifier() diff --git a/hy/lex/__init__.py b/hy/lex/__init__.py index e2e5a26..c32742e 100644 --- a/hy/lex/__init__.py +++ b/hy/lex/__init__.py @@ -4,11 +4,11 @@ from __future__ import unicode_literals +import keyword import re import sys import unicodedata -from hy._compat import isidentifier from hy.lex.exceptions import PrematureEndOfInput, LexException # NOQA from hy.models import HyExpression, HySymbol @@ -191,3 +191,11 @@ def read(from_file=sys.stdin, eof=""): def read_str(input): return read(StringIO(str(input))) + + +def isidentifier(x): + if x in ('True', 'False', 'None'): + return True + if keyword.iskeyword(x): + return False + return x.isidentifier()