This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-03-10
Channels
- # announcements (1)
- # babashka (44)
- # beginners (188)
- # calva (37)
- # chlorine-clover (28)
- # cider (12)
- # clj-kondo (40)
- # clojars (1)
- # clojure (323)
- # clojure-austin (7)
- # clojure-europe (20)
- # clojure-italy (4)
- # clojure-nl (16)
- # clojure-spec (7)
- # clojure-uk (37)
- # clojuredesign-podcast (1)
- # clojurescript (30)
- # cryogen (2)
- # cursive (30)
- # data-science (1)
- # datomic (26)
- # emacs (1)
- # events (1)
- # figwheel-main (13)
- # fulcro (89)
- # garden (1)
- # graalvm (20)
- # graphql (8)
- # jobs (1)
- # jobs-discuss (1)
- # joker (6)
- # kaocha (125)
- # lambdaisland (1)
- # meander (42)
- # off-topic (18)
- # pathom (3)
- # pedestal (6)
- # shadow-cljs (55)
- # spacemacs (21)
- # sql (18)
- # tools-deps (8)
- # uncomplicate (2)
- # vim (1)
- # yada (3)
clj-kondo
warns here:
src\app\lib\vk\java_sdk\core.clj:10:47: warning: Unused import GetResponse
src\app\lib\vk\java_sdk\core.clj:12:35: warning: Unused import DomainResolved
but imports are used in type hints.
@borkdude is it a bug or I missed something?seems like a false positive when using type hints in ->
. welcome to post a repro with a minimal example in an issue
@serioga I do always forget the right place to type hints, but if I remember correctly, you have your return type hints in the wrong place
(defn ^:private ^ServiceActor conn-service-actor
"Service actor from connection."
[{:keys [::app-id
::app-service-token]}]
(ServiceActor. app-id app-service-token))
Like so:
(defn ^:private conn-service-actor
"Service actor from connection."
^ServiceActor [{:keys [::app-id
::app-service-token]}]
(ServiceActor. app-id app-service-token))
Maybe But I've put type hints to get rid of warning from Cursive and reflection warning π
> For function return values, the type hint can be placed before the arguments vector
When you type hint where you did, you're type hinting the Var, but the Var holds a Fn, so its correct type is Fn, not ServiceActor
@didibus are we talking about this code fragment?
(try
(-> vk-api-client
(.friends)
(.get (conn-service-actor conn))
(.userId (Integer/parseInt user-id))
^GetResponse (.execute)
(.getItems)
(->> (mapv str)))
(catch ApiAccessException _
(private-profile-friends))
(catch ApiPrivateProfileException _
(private-profile-friends)))
I'm talking about:
(defn ^:private ^ServiceActor conn-service-actor
"Service actor from connection."
[{:keys [::app-id
::app-service-token]}]
(ServiceActor. app-id app-service-token))
there is not warning about this https://clojurians.slack.com/archives/CHY97NXE2/p1583871935143100
I just mean, in your function signature, I think the correct place to type hint the return value is the args vector
βI think the correct place to type hint the return value is the args vectorβ Agree I also think those hints are useless But I did not know this when wrote that code π
@borkdude what do you think? π https://clojurians.slack.com/archives/CHY97NXE2/p1583872276147100
Shall we focus on the first issue first (type hints in threading macros do prevent from unused import warnings). I haven't seen a Github issue for that yet π
@borkdude https://github.com/borkdude/clj-kondo/issues/795 new (I think) false positive
@serioga I think this is a minimal repro for your issue:
$ clj-kondo --lint - <<< '(ns foo (:import [foo Bar])) (defn foo [x] x) (defn bar [x] (-> x ^Bar (foo)))'
<stdin>:1:23: warning: Unused import Bar
linting took 11ms, errors: 0, warnings: 1
@tanzoniteblack Thanks, duplicate of #787
I saw that one and wasn't clear they were duplicates of each other or not
seemed like the same error, but probably due to different reasons
@serioga Filed your issue here now: https://github.com/borkdude/clj-kondo/issues/796

@tanzoniteblack I might have closed it prematurely. I'll take another look.