clj-python / libpython-clj

Python bindings for Clojure
Eclipse Public License 2.0
1.06k stars 69 forks source link

clj-kondo hooks #135

Closed sogaiu closed 3 years ago

sogaiu commented 3 years ago

This PR is an attempt at providing support for clj-kondo hooks in libpython-clj. For details on the specific hooks please see: https://github.com/clj-python/clj-template/pull/9

The idea here is to bundle the hooks with libpython-clj itself so that users can obtain the relevant hook code from the library (whether it's via a .jar or a git dep) itself and not have to go looking elsewhere nor figure out which version of the hook code is appropriate.

Note that getting the hook code into place and activated in one's project is a process that involves user intervention -- it is not just a matter of obtaining libpython-clj or updating a libpython-clj dependency.

The process subsequent to updating libpython-clj is basically:

0) Ensure there is already a .clj-kondo directory in the project's top-level directory 1) Execute an appropriate clj-kondo command to copy hooks code from the library to beneath the .clj-kondo directory 2) Possibly create / edit .clj-kondo/config.edn appropriately

The following comment contains a log of this process for libpython-clj: https://github.com/clj-kondo/config/issues/1#issuecomment-723370532 [1]

Documentation for this feature can be found at: https://github.com/borkdude/clj-kondo/blob/master/doc/config.md#Exporting-and-importing-configuration

Note that versions of clj-kondo earlier than v2020.11.07 are not likely to work.


[1] Slight gotcha with the instructions -- initially I used "clj_python" as a directory name, but was told this could be "clj-python". This change has been reflected in this PR.

cnuernber commented 3 years ago

@sogaiu - is this ready to merge?

sogaiu commented 3 years ago

Was thinking it might be good to have at least one report of success for at least one other person, but haven't heard of any tests yet.

I think @jjtolton said he might have some time in December.

WDYT?

cnuernber commented 3 years ago

If you are happy I am happy. I don't use Kondo and I definitely understand wanting another user to check it out.

jjtolton commented 3 years ago

Tested, works great. Approved! Thanks for the guidance, @sogaiu

PlumpMath commented 3 years ago

It's like watching an (White Snake/A Chinese Ghost Story). What a beautiful world.

sogaiu commented 3 years ago

@jjtolton Thanks for taking a look and testing!

My current feeling is that perhaps the current code can give folks a taste of what can be done to customize clj-kondo's behavior for use with libpython-clj.

I'm fine to consider / work on some other bits once it's clear there are specific requests -- though may be in many cases it will be easy enough for other folks to contribute too :)

How does that sound?

jjtolton commented 3 years ago

I think it's great. We'll get some docs together on how to use it!

sogaiu commented 3 years ago

Sorry if this is off-topic, hope it will be tolerated :)

@PlumpMath I don't understand the reference -- would you mind giving some hints?

PlumpMath commented 3 years ago

@sogaiu I'm not sure about that either. We don't even know forever? hahaha Thanks.