Skip to content

Commit c8944d8

Browse files
committed
Add lint-as for py/with
1 parent 3daa683 commit c8944d8

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

resources/clj-kondo.exports/clj-python/libpython-clj/config.edn

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
{:hooks
1+
{:lint-as {libpython-clj2.python/with clojure.core/with-open}
2+
3+
:hooks
24
{:analyze-call {libpython-clj.jna.base/def-pylib-fn
35
hooks.libpython-clj.jna.base.def-pylib-fn/def-pylib-fn
46

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
(ns clj-kondo.fixtures.py-with-test
2+
(:require [libpython-clj2.python :as py]))
3+
4+
(defn test-py-with [testcode]
5+
(py/with [f (py/call-attr testcode "FileWrapper" "content")]
6+
(py/call-attr f "read")))

test/clj_kondo/hook_test.clj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,10 @@
4545
output (str out err)]
4646
(is (not (has-py-dot-errors? output))
4747
(str "Found py. related errors in output:\n" output)))))
48+
49+
(deftest py-with-test
50+
(testing "py_with_test.clj - py/with binding"
51+
(let [{:keys [out err]} (run-clj-kondo (str fixtures-dir "/py_with_test.clj"))
52+
output (str out err)]
53+
(is (not (re-find #"Unresolved symbol: f" output))
54+
(str "py/with binding not recognized:\n" output)))))

0 commit comments

Comments
 (0)