Enable usage of custom pylintrc file for message documentation tests#6131
Conversation
… and demonstrate it with optional checker message as example.
Pull Request Test Coverage Report for Build 2082161191
💛 - Coveralls |
Pierre-Sassoulas
left a comment
There was a problem hiding this comment.
Thanks you @DudeNr33 !
| @@ -0,0 +1,2 @@ | |||
| Following an indented ``if`` block directly with an ``elif`` of lower indentation can lead to confusion whether the unindent is deliberate or accidental. | |||
| Adding an explicit ``else`` in the indented ``if`` statement, even if it only contains a ``pass`` statement, can help clarify the code. | |||
There was a problem hiding this comment.
| Adding an explicit ``else`` in the indented ``if`` statement, even if it only contains a ``pass`` statement, can help clarify the code. | |
| Creating a function for the nested conditional, or adding an explicit ``else`` in the indented ``if`` statement, even if it only contains a ``pass`` statement, can help clarify the code. |
| config_file = next(config.find_default_config_files(), None) | ||
| # Check if this message has a custom configuration file (e.g. for enabling optional checkers). | ||
| # If not, use the default configuration. | ||
| config_file: Optional[Path] |
There was a problem hiding this comment.
@DanielNoord I think we talked about this already before but what do you think about using FunctionalTestFile instead here ? At some point we will encounter the same issue than for functional tests (i.e. handling min_version, max_version, some options...). We could do test_file.option_file instead of recreating the logic a little differently.
There was a problem hiding this comment.
That was actually my initial approach, but the problem is that FunctionalTestFile assumes the config file to have the same name as the .py file.
There is quite a good portion of code duplication also in the LintModuleTest class here.
Besides the different folder structure, the tight coupling between the "original" LintModuleTest and test_functional.py is another problem.
There was a problem hiding this comment.
Yeah, I advise against trying to use LintModuleTest here. The idea is similar but because of the different folder structures it doesn't really work.
It's similar to your Duck vs. PlasticDuck example @Pierre-Sassoulas 😄
To ease the process of reviewing your PR, do make sure to complete the following boxes.
and preferred name in
script/.contributors_aliases.jsonType of Changes
Description
In order to test some messages (e.g. for messages of optional checkers), we need a way to use a custom config.
With this modification it is possible to place a
pylintrcfile next togood.pyandbad.py.To prove it works I added a documentation example for one of the optional checkers.
Ref: #5953 (comment)