WIP: clj-kondo hooks for require-python#277
Draft
jjtolton wants to merge 10 commits intoclj-python:masterfrom
Draft
WIP: clj-kondo hooks for require-python#277jjtolton wants to merge 10 commits intoclj-python:masterfrom
jjtolton wants to merge 10 commits intoclj-python:masterfrom
Conversation
- 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
clj-kondo config exports for libpython-clj2
Closes #268