File tree Expand file tree Collapse file tree 4 files changed +35
-1
lines changed
resources/clj-kondo.exports/clj-python/libpython-clj
hooks/libpython_clj/python Expand file tree Collapse file tree 4 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 1010 libpython-clj.require/require-python
1111 hooks.libpython-clj.require.require-python/require-python
1212 libpython-clj2.require/require-python
13- hooks.libpython-clj.require.require-python/require-python}}
13+ hooks.libpython-clj.require.require-python/require-python
14+
15+ libpython-clj2.python/py..
16+ hooks.libpython-clj.python.py-dot-dot/py..
17+ libpython-clj2.python/py.
18+ hooks.libpython-clj.python.py-dot-dot/py..}}
1419
1520 :linters
1621 {:unresolved-namespace
Original file line number Diff line number Diff line change 1+ (ns hooks.libpython-clj.python.py-dot-dot
2+ (:require [clj-kondo.hooks-api :as api]))
3+
4+ (defn py..
5+ " Transform py.. to just evaluate the object, ignoring method/attribute symbols.
6+ (py.. obj method arg) -> obj"
7+ [{:keys [node]}]
8+ (let [children (:children node)
9+ obj-node (second children)]
10+ (if obj-node
11+ {:node obj-node}
12+ {:node (api/token-node nil )})))
Original file line number Diff line number Diff line change 1+ (ns clj-kondo.fixtures.py-dot-test
2+ (:require [libpython-clj2.python :refer [py. py..]]))
3+
4+ (defn test-py-dot []
5+ (let [obj {:foo " bar" }]
6+ (py. obj method arg1 arg2)
7+ (py.. obj method1 method2 method3)))
Original file line number Diff line number Diff line change 3535 (str " Found require-python errors in output:\n " output))
3636 (is (not (has-unresolved-refer-errors? output))
3737 (str " Found unresolved symbol errors for referred symbols:\n " output)))))
38+
39+ (defn- has-py-dot-errors? [output]
40+ (boolean (re-find #"(Unresolved symbol: py\. |unresolved var.*py\. )" output)))
41+
42+ (deftest py-dot-hook-test
43+ (testing " py_dot_test.clj - py. and py.. macros"
44+ (let [{:keys [out err]} (run-clj-kondo (str fixtures-dir " /py_dot_test.clj" ))
45+ output (str out err)]
46+ (is (not (has-py-dot-errors? output))
47+ (str " Found py. related errors in output:\n " output)))))
You can’t perform that action at this time.
0 commit comments