Fork me on GitHub
#clj-kondo
<
2020-09-26
>
borkdude07:09:28

@kevin26428 can you elaborate?

sogaiu10:09:06

@borkdude there is a construct in libpython-clj which appears to make certain namespaces / aliases available. it is called import-python. after it is evaluated, 7 namespaces / aliases become available. do you have a recommendation as to how to teach clj-kondo about this construct using hooks?

sogaiu10:09:03

for starters i tried constructing a do form containing a require form, but i'm getting the sense that may not work.

borkdude12:09:06

@sogaiu Maybe:

(comment
  (require 'python.list))
(python.list/hi)

sogaiu12:09:59

@borkdude i see that that works in an editor, thanks. i tried with:

(comment
  (require (quote python.list)))
(python.list/hi)
but that doesn't seem to work in my editor. how do i construct a quoted form (i.e. using single quote) using the hooks api? i thought i might need to use rewrite-clj's quote-node but that doesn't appear to be in the hooks api. may be there is another way?

borkdude12:09:42

Hmm, clj-kondo's handling of require might not understand that currently. That's something to fix. But since you are writing a hook, this won't be emitted top level anyway?

borkdude12:09:49

clj-kondo only parses top-level requires currently

borkdude12:09:12

or are you handling import-python at the top level?

sogaiu12:09:39

i think the typical place to use it is at top level, but doesn't the hooks api only let us return one node?

borkdude12:09:01

this is very co-incidental: I fixed a similar thing in sci recently: macros emitting top-level dos

borkdude12:09:49

I think there's two things to post issues for: - clj-kondo should handle requires in top-level dos - clj-kondo should handle require with quote

sogaiu12:09:08

ok, i'm fine to make those if you like.

borkdude12:09:35

yeah please. I'm about to start a new 2 week Clojurists Together cycle for clj-kondo :)

sogaiu12:09:45

cool, will do.

borkdude16:09:29

Sophisticated CI script using babashka and clj-kondo in Gitlab: https://gist.github.com/hansbugge/4be701d771057e8ef6bbbb0912656355