Skip to content
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

docs: Change --indent-string's whitespace representation #9904

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/user_guide/configuration/all-options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -904,9 +904,9 @@ Standard Checkers

--indent-string
"""""""""""""""
*String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 tab).*
*String used as indentation unit. This is usually "    " (4 spaces) or "\t" (1 tab).*

**Default:** `` ``
**Default:** ``" "``


--max-line-length
Expand Down
4 changes: 4 additions & 0 deletions doc/whatsnew/fragments/8392.other
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Ensure the default value of 4 spaces for the `--indent-string` flag
does not compress when using reStructuredText to make docs.

Closes #8392
4 changes: 2 additions & 2 deletions pylint/checkers/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,11 @@ class FormatChecker(BaseTokenChecker, BaseRawFileChecker):
(
"indent-string",
{
"default": " ",
"default": '" "',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change thΓ© default value in the code, it's going to cause problem. There's a mechanism in place to modify the default value for the doc but not the code, see enchent dict of available language for the spell checker or default python interpreter. (On mobile, can't link to the exact place Sorry)

Copy link
Contributor Author

@rogersheu rogersheu Sep 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Yeah, I can see how this might cause a problem.

I'm looking at the arguments for enchant. Is this the one you had in mind?

        (
            "spelling-dict",
            {
                "default": "",
                "type": "choice",
                "metavar": "<dict name>",
                "choices": _get_enchant_dict_choices(enchant_dicts),
                "help": _get_enchant_dict_help(enchant_dicts, PYENCHANT_AVAILABLE),
            },
        ),
...

I see what's happening here, with functions being passed into choices/help, but the real issue is that default has to be four spaces, , exactly to make sure the default remains correct. This means that the value has to be different when interpreted for the conversion to reStructuredText.

Does adding such functionality sound like a reasonable path forward for this PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Back on a PC πŸ˜„ I meant this:

DYNAMICALLY_DEFINED_OPTIONS: dict[str, dict[str, str]] = {
# Option name, key / values we want to modify
"py-version": {"default": "sys.version_info[:2]"},
"spelling-dict": {
"choices": "Values from 'enchant.Broker().list_dicts()' depending on your local enchant installation",
"help": "Spelling dictionary name. Available dictionaries depends on your local enchant installation",
},
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing me to this @Pierre-Sassoulas !!

Been busy with work lately, but I'm hoping to find a little time to test out this change soon. πŸ˜…

"type": "non_empty_string",
"metavar": "<string>",
"help": "String used as indentation unit. This is usually "
'" " (4 spaces) or "\\t" (1 tab).',
'"    " (4 spaces) or "\\t" (1 tab).', # noqa: RUF001
},
),
(
Expand Down
Loading