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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Backpush to main changes to skeleton of python hooks #741
base: master
Are you sure you want to change the base?
chore: Backpush to main changes to skeleton of python hooks #741
Changes from 69 commits
18291bd
9409f77
ef844ce
806a87a
3f3fdd9
a37971b
85269df
8fbba99
0421801
1f956dc
59b6bac
79ac415
93cddb7
0280a60
a14589a
b1a466c
06d4fc6
878f5bd
dae3af2
f99ca4a
c254a5b
0cdbaec
e5914e0
c033767
01a5850
c7c8e56
fe92d45
e010c8a
4c459df
33e1547
7d9ba2f
3a59fe4
7d96f1b
0c267ee
a3e4252
db3fefd
00674ef
b6aa20b
60f1292
7dde1df
52cf580
c03e3fe
aa71534
3285431
96e44ef
2c8b44b
934202f
3cbc220
7e647ad
0defc96
7b3cc6c
f1d8faf
2e54190
1f525fc
79b633e
294cf79
f1673ce
0e03e68
83c7a29
650d90c
8953dd9
53e2dd0
3cf99fd
89e5a45
c2aab92
449d448
ac42c51
a278a04
0799817
d3df63b
56ab01e
f622b10
c65ecf6
14f9d2a
1bdb83e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pre-commit-terraform
repo I guessargs: […]
) or multiline (as in YAML sequence) and definitely w/o single-line arrays split to multiline please.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also have this sort of comments in a draft review that I haven't yet posted in #743.
On the CLI settings, they should almost never be used not because of the defaults but because any other calls to those tools (like IDE extensions automatically picking them up w/o the user configuring anything) would not consume these settings and will result in different sets of violations reported and different behaviors of tools that aren't linters.
And for consistency, I'd rather enforce
yamllint
. I can send in my default config separately.Additionally, the organization of integrations in this config is suboptimal that I'll expand on in the other review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xref #747
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't accept this just yet. It shouldn't even be in this config. See my other comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plz, stick to kebab-case CLI arguments. It's rather uncommon to use snake_case in CLIs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to maintain one name across everything to not create more entropy.
If hook has named
terraform_docs_replace
it MUST be called this way everywhere, no matter what.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the thing — the only place for the hook subcommand name is the constant in the module, not the module itself.
terraform_docs_replace.py
is just a Python module that backs it, not a hook. The hook name would beterraform-docs-replace
. This is a common convention, and the underlying implementation details shouldn't leak into UI/UX.Here's some discussion in other popular CLI frameworks: fastapi/typer#341
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's some public arguments discussing the ergonomics of having to use Shift-key vs. not, leaning towards kebab-space or no-delimiter:
Do you have many programs on your system that have
snake_case
CLIs? Could you name a few?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should also check the tests dirs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably just be picked into master directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's common to list which environments it's being tested under. And additionally, the most important bit in the metadata would be the
requires-python
value. The classifiers are for humans to read, but the Python requirement is for the dependency resolver to actually take into account.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed. And also, I've got a proper config in #742 anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will conflict with a fix in #742 FYI (this specific import is being dropped).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This API doc style is non-native to Sphinx. You might have to specify it in
.darglint
. But beware that darglint is deprecated and its parsing of non-native docstrings is known to be extremely slow. I once debugged it to a single Python file being linted during 11 minutes when I forgot to specify that I wanted the native one.Here's the native syntax FYI: https://www.sphinx-doc.org/en/master/usage/domains/python.html#info-field-lists.
I haven't checked if WPS replaced darglint w/ something else, it might not be as bad.
Also, with some Sphinx extensions, there shouldn't be a need to duplicate the argument types in docstrings. Plus, since you don't have Sphinx, this is definitely not something you should be spending additional time on. Just describe the args and the return value, omitting the types as it's not worth it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, what Google use then for docs, if that's not suported by Sphinx
https://google.github.io/styleguide/pyguide.html#383-functions-and-methods
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a custom style that's not enabled by default. It's implemented by the napoleon extension: https://sphinxcontrib-napoleon.rtfd.io / https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There could be not only
terraform
, buttofu
,terraform-alpha-1.11.2025.99.99
etcThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then let's abstract the name, like f.e.:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still maintain that it'd be useful to allow
--help
in subcommands.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, but that's out of scope for now - firstly we need to reimplement same hooks in Python w/o any breaking changes about what we are aware.
Anyway, I added that as TODO in
rewrite_hooks_on_python
branchThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only the docstring title needs to be in imperative mood. The long description paragraph doesn't need to do that, it can be more explanatory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FTR #742 has proper configuration that can work with relative imports just fine.