Skip to content

Conversation

@jjtolton
Copy link
Contributor

@jjtolton jjtolton commented Nov 30, 2025

clj-kondo config exports for libpython-clj2

Closes #268

- Add hook for libpython-clj2.require/import-python (v2 namespace)
- Add lint-as rules for require-python (v1 and v2)
- Add :unresolved-namespace exclusions for python.* namespaces
- Extend :unused-namespace exclusions to include python.* aliases

The existing config only covered the legacy libpython-clj namespace.
Users of libpython-clj2 were getting various warnings:
- "Unresolved namespace python" when using python.str, python.list, etc.
- "Unknown require option: :bind-ns" from require-python

Note: py., py.., py.-, py*, py** macros are now natively supported
in clj-kondo 2025.04.07+ (issue #2512) and don't need special config.

Closes clj-python#268
- Add require_python.clj hook that transforms require-python calls
  into standard require forms that clj-kondo can analyze
- Strip libpython-specific flags: :bind-ns, :reload, :no-arglists
- Generate def forms for :bind-ns vars and :refer symbols
- Handle :refer with vectors, :all, or :*
- Support both v1 (libpython-clj.require) and v2 (libpython-clj2.require)
- Replace :lint-as approach with proper analyze-call hooks

This eliminates false positive "Unknown require option" warnings
for libpython-clj's Python interop macros.
- Add test fixtures exercising all require-python patterns
- Add test-clj-kondo-hooks.sh for direct hook testing
- Add test-copy-configs.sh for end-to-end config testing
- Add clj-kondo-hooks CI job (runs before unit tests, no JVM/Python needed)

Test coverage includes:
- :bind-ns, :reload, :no-arglists flags
- :refer with vectors, :all, and :*
- Multiple specs in single require-python call
- import-python builtin namespace aliases
Adds a deps.edn alias to run clj-kondo hook tests locally:
  clj -M:clj-kondo-test

This runs the same hook verification tests as CI but via
the Clojure test-runner instead of shell scripts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

py. syntax is doing weird things with the clj-kondo linter

1 participant