pylint icon indicating copy to clipboard operation
pylint copied to clipboard

Improve docs clarity on loading custom checkers

Open daogilvie opened this issue 2 years ago • 5 comments

Type of Changes

Type
:scroll: Docs

Description

Short

This PR just updates the documentation page on writing custom checkers. It adds information about some restrictions between how init-hook changes the loading path and when you can use that to import your custom module.

Long (in the commit message)

Whilst the docs on testing custom checkers do touch on the fact the module has to be in your load path, there are some restrictions that were not made clear before. Specifically, the init-hook configuration item (which is often used explicitly to change the sys.path) is not automatically sufficient. If the init hook is in a file, but the load-plugins argument is passed in the CLI, then the plugins are loaded before the init-hook has run, and so will not be imported. In this case, the failure can also be silent, so the outcome is a lint that will simply not contain any information from the checker, as opposed to a run that will error. This corner case may merit fixing in a separate PR, that is to be confirmed.

Closes #7264

daogilvie avatar Aug 08 '22 14:08 daogilvie

@DanielNoord thank your for such a quick review! I've updated as per your suggestions, what do you think?

daogilvie avatar Aug 08 '22 14:08 daogilvie

Pull Request Test Coverage Report for Build 3008066091

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 215 unchanged lines in 18 files lost coverage.
  • Overall coverage increased (+0.08%) to 95.333%

Files with Coverage Reduction New Missed Lines %
pylint/checkers/modified_iterating_checker.py 1 97.7%
pylint/testutils/_primer/primer_command.py 1 95.65%
pylint/epylint.py 2 83.33%
pylint/extensions/docparams.py 2 98.53%
pylint/testutils/_primer/primer_compare_command.py 2 96.43%
pylint/utils/file_state.py 2 95.41%
pylint/lint/expand_modules.py 3 94.74%
pylint/testutils/_primer/primer_prepare_command.py 5 21.43%
pylint/checkers/classes/special_methods_checker.py 8 94.97%
pylint/config/find_default_config_files.py 8 89.16%
<!-- Total: 215
Totals Coverage Status
Change from base Build 2819506531: 0.08%
Covered Lines: 17017
Relevant Lines: 17850

💛 - Coveralls

coveralls avatar Aug 08 '22 15:08 coveralls

No problem! Thank you for very patiently reviewing my first attempt at a documentation PR 😂 I have some bad habits in terms of brevity and language to unlearn.

I'll make the changes above and then, as you say, pause this until after any potential changes in behaviour.

daogilvie avatar Aug 08 '22 16:08 daogilvie

Side note: I have made the commits individually in the UI for convenience, as your suggestions made sense to me straight away. Is that something you as maintainers prefer or dislike? Would it be better to have one commit for all recommendations? I didn't seem to have the "add to batch" button available.

daogilvie avatar Aug 08 '22 17:08 daogilvie

Side note: I have made the commits individually in the UI for convenience, as your suggestions made sense to me straight away. Is that something you as maintainers prefer or dislike?

Usually I/We prefer one commit, but it doesn't matter too much. As long as you don't rebase or force push the Github UI is pretty good at showing what changed and what remained the same after new commits.

Would it be better to have one commit for all recommendations? I didn't seem to have the "add to batch" button available.

I know, very annoying. It only shows up in the files view which you can select at the top of PR. There you can add to batch and then do one single commit.

DanielNoord avatar Aug 08 '22 18:08 DanielNoord

@daogilvie should we close this ? It seems it would be a valuable addition to the doc ?

@DanielNoord why do we have a blocked label ?

Pierre-Sassoulas avatar Sep 07 '22 13:09 Pierre-Sassoulas

Oh goodness I completely forgot about this. It was blocked pending resolution of the other PR.

daogilvie avatar Sep 07 '22 13:09 daogilvie

I have just pushed a commit with the review fixes in, but I think my deletion of the previous fork has left this PR in a bad state. @DanielNoord @Pierre-Sassoulas I think I may have to close this PR and re-open a new one from the replacement fork for this to work. Do you mind?

daogilvie avatar Sep 19 '22 16:09 daogilvie

Not at all, don't hesitate to ping me for a review :)

Pierre-Sassoulas avatar Sep 19 '22 17:09 Pierre-Sassoulas

Replaced with #7502

daogilvie avatar Sep 20 '22 07:09 daogilvie

Not at all, don't hesitate to ping me for a review :)

I don't seem to be able to do this directly (the reviewers section of the PR gives me no options), sorry.

daogilvie avatar Sep 20 '22 07:09 daogilvie

You can use @Pierre-Sassoulas :)

Pierre-Sassoulas avatar Sep 20 '22 15:09 Pierre-Sassoulas