lispython 0.4.6__tar.gz → 0.4.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. {lispython-0.4.6 → lispython-0.4.7}/.gitignore +3 -1
  2. {lispython-0.4.6 → lispython-0.4.7}/PKG-INFO +1 -1
  3. {lispython-0.4.6 → lispython-0.4.7}/pyproject.toml +1 -1
  4. {lispython-0.4.6 → lispython-0.4.7}/src/lispy/core/compiler/expr.py +2 -1
  5. {lispython-0.4.6 → lispython-0.4.7}/src/lispy/core/macro.py +13 -8
  6. {lispython-0.4.6 → lispython-0.4.7}/src/lispy/core/nodes.py +1 -1
  7. {lispython-0.4.6 → lispython-0.4.7}/src/lispy/macros/sugar.lpy +2 -2
  8. {lispython-0.4.6 → lispython-0.4.7}/src/lispy/tools.lpy +13 -7
  9. {lispython-0.4.6 → lispython-0.4.7}/uv.lock +1 -1
  10. lispython-0.4.6/.claude/settings.local.json +0 -11
  11. {lispython-0.4.6 → lispython-0.4.7}/.pre-commit-config.yaml +0 -0
  12. {lispython-0.4.6 → lispython-0.4.7}/.vscode/settings.json +0 -0
  13. {lispython-0.4.6 → lispython-0.4.7}/LICENSE.md +0 -0
  14. {lispython-0.4.6 → lispython-0.4.7}/README.md +0 -0
  15. {lispython-0.4.6 → lispython-0.4.7}/docs/index.md +0 -0
  16. {lispython-0.4.6 → lispython-0.4.7}/docs/macros.md +0 -0
  17. {lispython-0.4.6 → lispython-0.4.7}/docs/syntax/expressions.md +0 -0
  18. {lispython-0.4.6 → lispython-0.4.7}/docs/syntax/overview.md +0 -0
  19. {lispython-0.4.6 → lispython-0.4.7}/docs/syntax/statements.md +0 -0
  20. {lispython-0.4.6 → lispython-0.4.7}/docs/usage/cli.md +0 -0
  21. {lispython-0.4.6 → lispython-0.4.7}/docs/usage/getting-started.md +0 -0
  22. {lispython-0.4.6 → lispython-0.4.7}/docs/version_macro.py +0 -0
  23. {lispython-0.4.6 → lispython-0.4.7}/docs/why-lispy.md +0 -0
  24. {lispython-0.4.6 → lispython-0.4.7}/mkdocs.yml +0 -0
  25. {lispython-0.4.6 → lispython-0.4.7}/src/lispy/__init__.py +0 -0
  26. {lispython-0.4.6 → lispython-0.4.7}/src/lispy/core/builtins.py +0 -0
  27. {lispython-0.4.6 → lispython-0.4.7}/src/lispy/core/compiler/__init__.py +0 -0
  28. {lispython-0.4.6 → lispython-0.4.7}/src/lispy/core/compiler/literal.py +0 -0
  29. {lispython-0.4.6 → lispython-0.4.7}/src/lispy/core/compiler/stmt.py +0 -0
  30. {lispython-0.4.6 → lispython-0.4.7}/src/lispy/core/compiler/utils.py +0 -0
  31. {lispython-0.4.6 → lispython-0.4.7}/src/lispy/core/importer.py +0 -0
  32. {lispython-0.4.6 → lispython-0.4.7}/src/lispy/core/meta_functions.py +0 -0
  33. {lispython-0.4.6 → lispython-0.4.7}/src/lispy/core/parser.py +0 -0
  34. {lispython-0.4.6 → lispython-0.4.7}/src/lispy/core/utils.py +0 -0
  35. {lispython-0.4.6 → lispython-0.4.7}/src/lispy/core_meta_functions.lpy +0 -0
  36. {lispython-0.4.6 → lispython-0.4.7}/src/lispy/lsp/__init__.py +0 -0
  37. {lispython-0.4.6 → lispython-0.4.7}/src/lispy/lsp/__main__.py +0 -0
  38. {lispython-0.4.6 → lispython-0.4.7}/src/lispy/lsp/server.lpy +0 -0
  39. {lispython-0.4.6 → lispython-0.4.7}/src/lispy/macros/__init__.py +0 -0
  40. {lispython-0.4.6 → lispython-0.4.7}/src/lispy/macros/init.lpy +0 -0
  41. {lispython-0.4.6 → lispython-0.4.7}/tests/__init__.py +0 -0
  42. {lispython-0.4.6 → lispython-0.4.7}/tests/test_as_thread.py +0 -0
  43. {lispython-0.4.6 → lispython-0.4.7}/tests/test_expr.py +0 -0
  44. {lispython-0.4.6 → lispython-0.4.7}/tests/test_gensym.py +0 -0
  45. {lispython-0.4.6 → lispython-0.4.7}/tests/test_include_meta.py +0 -0
  46. {lispython-0.4.6 → lispython-0.4.7}/tests/test_literal.py +0 -0
  47. {lispython-0.4.6 → lispython-0.4.7}/tests/test_literal_unwrap.py +0 -0
  48. {lispython-0.4.6 → lispython-0.4.7}/tests/test_meta_functions.py +0 -0
  49. {lispython-0.4.6 → lispython-0.4.7}/tests/test_parser.py +0 -0
  50. {lispython-0.4.6 → lispython-0.4.7}/tests/test_stmt.py +0 -0
  51. {lispython-0.4.6 → lispython-0.4.7}/tests/utils.py +0 -0
@@ -332,4 +332,6 @@ GEMINI.md
332
332
  .worktrees/
333
333
 
334
334
  # Agent-generated docs (not mkdocs content)
335
- docs/superpowers/
335
+ docs/superpowers/.stacks
336
+ .agents
337
+ .claude
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lispython
3
- Version: 0.4.6
3
+ Version: 0.4.7
4
4
  Summary: Lisp-like Syntax for Python with Lisp-like Macros
5
5
  Project-URL: Homepage, https://jetack.github.io/lispython
6
6
  Project-URL: Repository, https://github.com/jetack/lispython
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "lispython"
3
- version = "0.4.6"
3
+ version = "0.4.7"
4
4
  description = "Lisp-like Syntax for Python with Lisp-like Macros"
5
5
  authors = [{ name = "Jetack", email = "jetack23@gmail.com" }]
6
6
  license = { text = "MIT" }
@@ -107,7 +107,8 @@ def ifexp_p(sexp):
107
107
 
108
108
 
109
109
  def ifexp_compile(sexp):
110
- [_, test, body, orelse] = sexp.list
110
+ [_, test, body, *rest] = sexp.list
111
+ orelse = rest[0] if rest else Constant("None", **sexp.position_info)
111
112
  return ast.IfExp(
112
113
  test=expr_compile(test),
113
114
  body=expr_compile(body),
@@ -40,14 +40,19 @@ def define_macro(sexp, scope, include_meta=True):
40
40
 
41
41
  def require_macro(sexp, scope, include_meta=True):
42
42
  transformed = require_transform(sexp)
43
- eval(
44
- compile(
45
- ast.Interactive(body=macroexpand_then_compile([transformed], include_meta=include_meta)),
46
- "macro-requiring",
47
- "single",
48
- ),
49
- scope,
50
- )
43
+ try:
44
+ eval(
45
+ compile(
46
+ ast.Interactive(body=macroexpand_then_compile([transformed], include_meta=include_meta)),
47
+ "macro-requiring",
48
+ "single",
49
+ ),
50
+ scope,
51
+ )
52
+ except (ModuleNotFoundError, ImportError):
53
+ import sys
54
+ module_name = str(sexp.list[1])
55
+ print(f"l2py: warning: could not load macros from '{module_name}' (module not found)", file=sys.stderr)
51
56
  return transformed if include_meta else None
52
57
 
53
58
 
@@ -369,7 +369,7 @@ class Symbol(Literal):
369
369
 
370
370
  @property
371
371
  def name(self):
372
- return self.value.replace("-", "_")
372
+ return self.value.replace("->", "_to_").replace("-", "_").replace("?", "_p")
373
373
 
374
374
  def __repr__(self):
375
375
  return "Sym(" + self.value + ")"
@@ -5,8 +5,8 @@
5
5
  (return `(if ~test ~then (cond ~@orelse))))))
6
6
 
7
7
  (defmacro conde [*body]
8
- (if (< (len body) 4)
9
- (return `(ife ~@body))
8
+ (if (<= (len body) 2)
9
+ (return (sub body -1))
10
10
  (do (= [test then *orelse] body)
11
11
  (return `(ife ~test ~then (conde ~@orelse))))))
12
12
 
@@ -25,17 +25,21 @@
25
25
  (from lispy.core.parser [parse])
26
26
  (from lispy.core.macro [macroexpand macroexpand-then-compile])
27
27
 
28
+ (def has-init-file [dir-path]
29
+ (return (or (osp.exists (osp.join dir-path "__init__.py"))
30
+ (osp.exists (osp.join dir-path "__init__.lpy")))))
31
+
28
32
  (def detect-package-name [:path None]
29
- "Detect package name from directory by checking for __init__.py"
33
+ "Detect package name from directory by checking for __init__.py or __init__.lpy"
30
34
  (= dir-path (ife (is path None)
31
35
  (os.getcwd)
32
36
  (osp.dirname (osp.abspath path))))
33
- (if (not (osp.exists (osp.join dir-path "__init__.py")))
37
+ (if (not (has-init-file dir-path))
34
38
  (return ""))
35
39
  ;; Walk up to find package root
36
40
  (= parts [])
37
41
  (= current dir-path)
38
- (while (osp.exists (osp.join current "__init__.py"))
42
+ (while (has-init-file current)
39
43
  (parts.insert 0 (osp.basename current))
40
44
  (= parent (osp.dirname current))
41
45
  (if (== parent current)
@@ -114,9 +118,12 @@
114
118
 
115
119
  (def l2py-f [file-path :include-meta False :no-lispy False :format True]
116
120
  "Translate lispy file to Python source string (standalone with sys.path setup)"
117
- (= script-dir (osp.dirname (osp.abspath file-path)))
118
- (if (not (in script-dir sys.path))
119
- (sys.path.insert 0 script-dir))
121
+ ;; Detect package first so we add the right directory to sys.path
122
+ (= pkg (detect-package-name :path file-path))
123
+ (if (not pkg)
124
+ (do (= script-dir (osp.dirname (osp.abspath file-path)))
125
+ (if (not (in script-dir sys.path))
126
+ (sys.path.insert 0 script-dir))))
120
127
 
121
128
  ;; Clear cached macro modules to ensure fresh reload
122
129
  (= modules-to-remove [])
@@ -132,7 +139,6 @@
132
139
 
133
140
  (with [(open file-path "rb") as f]
134
141
  (= src (.decode (f.read) "utf-8")))
135
- (= pkg (detect-package-name :path file-path))
136
142
  (return (+ (l2py-s src :include-meta include_meta :fresh-scope True :package pkg :no-lispy no_lispy :format format) "\n")))
137
143
 
138
144
  (def l2py []
@@ -260,7 +260,7 @@ wheels = [
260
260
 
261
261
  [[package]]
262
262
  name = "lispython"
263
- version = "0.4.6"
263
+ version = "0.4.7"
264
264
  source = { editable = "." }
265
265
  dependencies = [
266
266
  { name = "prompt-toolkit" },
@@ -1,11 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(mike set-default:*)",
5
- "Bash(uv run python:*)",
6
- "Bash(uv run pytest:*)"
7
- ],
8
- "deny": [],
9
- "ask": []
10
- }
11
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes