Zulip Chat Archive
Stream: general
Topic: linter doc_blame with old_structure_cmd
Oliver Nash (Apr 13 2020 at 11:25):
The following snippet triggers the "missing doc string" complaint from the linter:
set_option old_structure_cmd true /-- Foo structure -/ structure foo := (x : ℕ) /-- Bar structure -/ structure bar extends foo := (y : ℕ) #lint -- #print bar.to_foo /- def missing doc string -/
Kenny Lau (Apr 13 2020 at 11:26):
then don't use old_structure_cmd
Oliver Nash (Apr 13 2020 at 11:26):
I note that even though Lean automatically created bar.to_foo
regardless of whether I'm using the old_structure_cmd
, it is only when this option is true (as above) that the linter complains.
Mario Carneiro (Apr 13 2020 at 11:26):
well it's not wrong
Oliver Nash (Apr 13 2020 at 11:26):
@Kenny Lau Oh really? It's much more convenient in some situations I think. I'd be happy to be corrected!
Kenny Lau (Apr 13 2020 at 11:27):
I was referring to the old joke "Doctor I feel painful when I breathe; doctor: then don't breathe"
Mario Carneiro (Apr 13 2020 at 11:27):
I would hate for this to be the reason you choose one method over the other
Oliver Nash (Apr 13 2020 at 11:27):
I had scanned some old threads here before deciding to use it and I thought the current wisdom was that it's fine to use it, and even that the name is a bit of a misnomer but really I'm far from sure.
Oliver Nash (Apr 13 2020 at 11:28):
@Kenny Lau Ah I see. :laughing:
Oliver Nash (Apr 13 2020 at 11:28):
@Mario Carneiro Noted, thanks. Perhaps I'll add an appropriate nolint
statement and allow the advice to flow in the code review.
Oliver Nash (Apr 13 2020 at 11:28):
Thank you both.
Mario Carneiro (Apr 13 2020 at 11:28):
you can also document it
Mario Carneiro (Apr 13 2020 at 11:29):
there is a command like add_doc_string
for adding doc strings to automatic definitions
Rob Lewis (Apr 13 2020 at 11:29):
The linter generally ignores auto-generated stuff but I guess this doesn't get flagged as auto-generated.
Gabriel Ebner (Apr 13 2020 at 11:29):
It's called add_decl_doc
.
Oliver Nash (Apr 13 2020 at 11:30):
OK thanks. It feels a bit funny to have to add a doc string to an auto-generated function but I am still glad to learn about add_decl_doc
.
Kevin Buzzard (Apr 13 2020 at 11:35):
You're right that the name is terrible. It implies it's deprecated, whereas in fact for part of the structure heirarchy it's exactly what we want.
Mario Carneiro (Apr 13 2020 at 11:38):
PR?
Mario Carneiro (Apr 13 2020 at 11:38):
How about flat_structure
instead
Oliver Nash (Apr 13 2020 at 11:38):
I literally just created one here: https://github.com/leanprover-community/mathlib/pull/2404
Oliver Nash (Apr 13 2020 at 11:38):
(I'm currently scanning it to make sure I haven't done anything stupid before I request review.)
Oliver Nash (Apr 13 2020 at 11:39):
I have not previously seen flat_structure
. I'd love to learn about it. I just grepped the Mathlib source but didn't find it anywhere!
Mario Carneiro (Apr 13 2020 at 11:39):
I just made the name up
Mario Carneiro (Apr 13 2020 at 11:39):
as an alternative to old_structure_cmd
which has wrong connotations
Oliver Nash (Apr 13 2020 at 11:39):
Oh I see: my comment about the possible misnomer. Yeah, flat_structure
is nice
Oliver Nash (Apr 13 2020 at 11:40):
I'd vote for that over old_structure_cmd
for sure.
Last updated: Dec 20 2023 at 11:08 UTC