From 484daafa5364bfd32178a3ecc14c7b9737def4c1 Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Thu, 2 Mar 2017 14:49:32 -0800 Subject: [PATCH] Move hy.core.reserved to hy.extra.reserved (#1231) It was an odd one out by being in hy.core but needing to be called by a qualified name. It's at home in hy.extra. --- NEWS | 1 + docs/extra/index.rst | 1 + docs/extra/reserved.rst | 19 +++++++++++++++++++ docs/language/core.rst | 21 --------------------- hy/core/__init__.py | 2 -- hy/{core => extra}/reserved.hy | 0 tests/native_tests/core.hy | 14 -------------- tests/native_tests/extra/reserved.hy | 14 ++++++++++++++ 8 files changed, 35 insertions(+), 37 deletions(-) create mode 100644 docs/extra/reserved.rst rename hy/{core => extra}/reserved.hy (100%) create mode 100644 tests/native_tests/extra/reserved.hy diff --git a/NEWS b/NEWS index f9cfc4c..89ce8c2 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,7 @@ Changes from 0.12.1 * Commas and underscores are allowed in numeric literals * with-decorator: Allow a `setv` form as the form to be decorated * xor: If exactly one argument is true, return it + * hy.core.reserved is now hy.extra.reserved [ Bug Fixes ] * Shadowed comparison operators now use `and` instead of `&` diff --git a/docs/extra/index.rst b/docs/extra/index.rst index 4748949..e0cbafc 100644 --- a/docs/extra/index.rst +++ b/docs/extra/index.rst @@ -12,3 +12,4 @@ Contents: :maxdepth: 3 anaphoric + reserved diff --git a/docs/extra/reserved.rst b/docs/extra/reserved.rst new file mode 100644 index 0000000..26f853f --- /dev/null +++ b/docs/extra/reserved.rst @@ -0,0 +1,19 @@ +============== +Reserved Names +============== + +names +===== + +Usage: ``(names)`` + +This function can be used to get a list (actually, a ``frozenset``) of the +names of Hy's built-in functions, macros, and special forms. The output +also includes all Python reserved words. All names are in unmangled form +(e.g., ``list-comp`` rather than ``list_comp``). + +.. code-block:: hy + + => (import hy.extra.reserved) + => (in "defclass" (hy.extra.reserved.names)) + True diff --git a/docs/language/core.rst b/docs/language/core.rst index 43c9ad6..652868f 100644 --- a/docs/language/core.rst +++ b/docs/language/core.rst @@ -1352,27 +1352,6 @@ Returns an iterator from *coll* as long as *pred* returns ``True``. => (list (take-while neg? [ 1 2 3 -4 5])) [] - -Other Built-Ins -=============== - -hy.core.reserved ----------------- - -Usage: ``(hy.core.reserved.names)`` - -This module can be used to get a list (actually, a ``frozenset``) of the -names of Hy's built-in functions, macros, and special forms. The output -also includes all Python reserved words. All names are in unmangled form -(e.g., ``list-comp`` rather than ``list_comp``). - -.. code-block:: hy - - => (import hy) - => (in "defclass" (hy.core.reserved.names)) - True - - Included itertools ================== diff --git a/hy/core/__init__.py b/hy/core/__init__.py index b46670e..be885ce 100644 --- a/hy/core/__init__.py +++ b/hy/core/__init__.py @@ -1,5 +1,3 @@ -from . import reserved # noqa - STDLIB = [ "hy.core.language", "hy.core.shadow" diff --git a/hy/core/reserved.hy b/hy/extra/reserved.hy similarity index 100% rename from hy/core/reserved.hy rename to hy/extra/reserved.hy diff --git a/tests/native_tests/core.hy b/tests/native_tests/core.hy index 7859700..f35aabb 100644 --- a/tests/native_tests/core.hy +++ b/tests/native_tests/core.hy @@ -621,20 +621,6 @@ (assert-equal (list (accumulate [1 -2 -3 -4 -5] -)) [1 3 6 10 15])) -(defn test-reserved [] - (import [hy.core.reserved [names]]) - (assert (is (type (names)) frozenset)) - (assert (in "and" (names))) - (when PY3 - (assert (in "False" (names)))) - (assert (in "pass" (names))) - (assert (in "class" (names))) - (assert (in "defclass" (names))) - (assert (in "->" (names))) - (assert (in "keyword?" (names))) - (assert (not-in "foo" (names))) - (assert (not-in "hy" (names)))) - (defn test-complement [] "NATIVE: test complement" (def helper (complement identity)) diff --git a/tests/native_tests/extra/reserved.hy b/tests/native_tests/extra/reserved.hy new file mode 100644 index 0000000..cfe236f --- /dev/null +++ b/tests/native_tests/extra/reserved.hy @@ -0,0 +1,14 @@ +(import [hy.extra.reserved [names] hy._compat [PY3]]) + +(defn test-reserved [] + (assert (is (type (names)) frozenset)) + (assert (in "and" (names))) + (when PY3 + (assert (in "False" (names)))) + (assert (in "pass" (names))) + (assert (in "class" (names))) + (assert (in "defclass" (names))) + (assert (in "->" (names))) + (assert (in "keyword?" (names))) + (assert (not-in "foo" (names))) + (assert (not-in "hy" (names))))