Skip to content
Merged
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
28 changes: 17 additions & 11 deletions doc/exts/pylint_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def _get_all_options(linter: PyLinter) -> OptionsDataDict:
"""Get all options registered to a linter and return the data."""
all_options: OptionsDataDict = defaultdict(list)
for checker in sorted(linter.get_checkers()):
checker_name = checker.name
for option_name, option_info in checker.options:
changes_to_do = DYNAMICALLY_DEFINED_OPTIONS.get(option_name, {})
if changes_to_do:
Expand All @@ -68,7 +67,7 @@ def _get_all_options(linter: PyLinter) -> OptionsDataDict:
f"{new_value!r} (instead of {option_info[key_to_change]!r})"
)
option_info[key_to_change] = new_value
all_options[checker_name].append(
all_options[checker.name].append(
OptionsData(
option_name,
option_info,
Expand Down Expand Up @@ -133,6 +132,12 @@ def _create_checker_section(
):
value = [i.pattern for i in value]

# Sorting in order for the output to be the same on all interpreters
# Don't sort everything here, alphabetical order do not make a lot of sense
# for options most of the time. Only dict based 'unstable' options need this
if isinstance(value, (list, tuple)) and option.name in ["disable"]:
value = sorted(value, key=lambda x: str(x))

# Add to table
checker_table.add(option.name, value)
checker_table.add(tomlkit.nl())
Expand Down Expand Up @@ -170,21 +175,22 @@ def _write_options_page(options: OptionsDataDict, linter: PyLinter) -> None:
get_rst_title("Standard Checkers", "^"),
]
found_extensions = False

for checker, checker_options in options.items():
# We can't sort without using the 'key' keyword because if keys in 'options' were
# checkers then it wouldn't be possible to have a checker with the same name
# spanning multiple classes. It would make pylint plugin code less readable by
# forcing to use a single class / file.
for checker_name, checker_options in sorted(
options.items(), key=lambda x: x[1][0].checker
):
if not found_extensions and checker_options[0].extension:
sections.append(get_rst_title("Extensions", "^"))
found_extensions = True
sections.append(_create_checker_section(checker, checker_options, linter))
sections.append(_create_checker_section(checker_name, checker_options, linter))

sections_string = "\n\n".join(sections)
all_options_path = PYLINT_USERGUIDE_PATH / "configuration" / "all-options.rst"
sections_string = "\n\n".join(sections)
with open(all_options_path, "w", encoding="utf-8") as stream:
stream.write(
f"""

{sections_string}"""
)
stream.write(f"\n\n{sections_string}")


# pylint: disable-next=unused-argument
Expand Down
2 changes: 1 addition & 1 deletion doc/user_guide/configuration/all-options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ Standard Checkers

confidence = ["HIGH", "CONTROL_FLOW", "INFERENCE", "INFERENCE_FAILURE", "UNDEFINED"]

disable = ["raw-checker-failed", "bad-inline-option", "locally-disabled", "file-ignored", "suppressed-message", "useless-suppression", "deprecated-pragma", "use-implicit-booleaness-not-comparison-to-string", "use-implicit-booleaness-not-comparison-to-zero", "use-symbolic-message-instead", "consider-using-augmented-assign", "prefer-typing-namedtuple"]
disable = ["bad-inline-option", "consider-using-augmented-assign", "deprecated-pragma", "file-ignored", "locally-disabled", "prefer-typing-namedtuple", "raw-checker-failed", "suppressed-message", "use-implicit-booleaness-not-comparison-to-string", "use-implicit-booleaness-not-comparison-to-zero", "use-symbolic-message-instead", "useless-suppression"]

enable = []

Expand Down