clj-kondo

https://github.com/clj-kondo/clj-kondo
borkdude 2020-09-26T07:01:28.025200Z

@kevin26428 can you elaborate?

2020-09-26T10:33:06.026700Z

@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?

2020-09-26T10:34:03.027400Z

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

2020-09-26T10:38:08.027500Z

borkdude 2020-09-26T12:01:06.027900Z

@sogaiu Maybe:

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

2020-09-26T12:10:59.030700Z

@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?

borkdude 2020-09-26T12:13:42.032200Z

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?

borkdude 2020-09-26T12:13:49.032500Z

clj-kondo only parses top-level requires currently

2020-09-26T12:14:06.032900Z

ah i see.

borkdude 2020-09-26T12:14:12.033200Z

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

2020-09-26T12:14:39.033900Z

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

borkdude 2020-09-26T12:15:01.034300Z

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

2020-09-26T12:15:10.034500Z

🙂

borkdude 2020-09-26T12:15:49.035300Z

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

2020-09-26T12:16:08.035700Z

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

borkdude 2020-09-26T12:16:35.036200Z

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

2020-09-26T12:16:45.036400Z

cool, will do.

borkdude 2020-09-26T16:13:29.037100Z

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