Skip to content

[pre-commit.ci] pre-commit autoupdate #10412

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

Merged
merged 5 commits into from
Jun 21, 2025
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
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ repos:
doc/data/messages/m/missing-final-newline/bad/crlf.py
)$
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.11.11"
rev: "v0.12.0"
hooks:
- id: ruff
- id: ruff-check
args: ["--fix"]
exclude: doc/data/messages
- id: ruff
- id: ruff-check
name: ruff-doc
files: doc/data/messages
- repo: https://github.com/Pierre-Sassoulas/copyright_notice_precommit
Expand Down Expand Up @@ -121,14 +121,14 @@ repos:
files: ^(doc/whatsnew/fragments)
exclude: doc/whatsnew/fragments/_.*.rst
- repo: https://github.com/rstcheck/rstcheck
rev: "v6.2.4"
rev: "v6.2.5"
hooks:
- id: rstcheck
args: ["--report-level=warning"]
files: ^(doc/(.*/)*.*\.rst)
additional_dependencies: [Sphinx==7.4.3]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.15.0
rev: v1.16.1
hooks:
- id: mypy
name: mypy
Expand All @@ -154,7 +154,7 @@ repos:
args: ["--max-summary-lines=2", "--linewrap-full-docstring"]
files: "pylint"
- repo: https://github.com/PyCQA/bandit
rev: 1.8.3
rev: 1.8.5
hooks:
- id: bandit
args: ["-r", "-lll"]
Expand Down
3 changes: 3 additions & 0 deletions doc/data/ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ line-length = 103
extend-exclude = [
"messages/d/duplicate-argument-name/bad.py",
"messages/s/syntax-error/bad.py",
# syntax error in newer python versions
"messages/s/star-needs-assignment-target/bad.py",
"messages/i/invalid-star-assignment-target/bad.py"
]

[lint]
Expand Down
1 change: 0 additions & 1 deletion pylint/checkers/base/basic_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def report_by_type_stats(
# percentage of different types documented and/or with a bad name
nice_stats: dict[str, dict[str, str]] = {}
for node_type in ("module", "class", "method", "function"):
node_type = cast(Literal["function", "class", "method", "module"], node_type)
total = stats.get_node_count(node_type)
nice_stats[node_type] = {}
if total != 0:
Expand Down
9 changes: 3 additions & 6 deletions pylint/checkers/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,11 @@ def visit_decorators(self, node: nodes.Decorators) -> None:
if qname in self.deprecated_decorators():
self.add_message("deprecated-decorator", node=node, args=qname)

@utils.only_required_for_messages(
"deprecated-module",
"deprecated-class",
)
@utils.only_required_for_messages("deprecated-module", "deprecated-class")
def visit_importfrom(self, node: nodes.ImportFrom) -> None:
"""Triggered when a from statement is seen."""
basename = node.modname
basename = get_import_name(node, basename)
basename = get_import_name(node, node.modname)
assert basename is not None, "Module name should not be None"
self.check_deprecated_module(node, basename)
class_names = (name for name, _ in node.names)
self.check_deprecated_class(node, basename, class_names)
Expand Down
10 changes: 5 additions & 5 deletions pylint/checkers/nested_min_max.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ def visit_call(self, node: nodes.Call) -> None:
end_col_offset=0,
)
splat_node.value = arg
fixed_node.args = (
fixed_node.args[:idx]
+ [splat_node]
+ fixed_node.args[idx + 1 : idx]
)
fixed_node.args = [
*fixed_node.args[:idx],
splat_node,
*fixed_node.args[idx + 1 : idx],
]

self.add_message(
"nested-min-max",
Expand Down
3 changes: 1 addition & 2 deletions pylint/checkers/raw_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from __future__ import annotations

import tokenize
from typing import TYPE_CHECKING, Any, Literal, cast
from typing import TYPE_CHECKING, Any, Literal

from pylint.checkers import BaseTokenChecker
from pylint.reporters.ureports.nodes import Paragraph, Section, Table, Text
Expand All @@ -25,7 +25,6 @@ def report_raw_stats(
sect.insert(0, Paragraph([Text(f"{total_lines} lines have been analyzed\n")]))
lines = ["type", "number", "%", "previous", "difference"]
for node_type in ("code", "docstring", "comment", "empty"):
node_type = cast(Literal["code", "docstring", "comment", "empty"], node_type)
total = stats.code_type_count[node_type]
percent = float(total * 100) / total_lines if total_lines else None
old = old_stats.code_type_count[node_type] if old_stats else None
Expand Down
2 changes: 1 addition & 1 deletion pylint/config/argument.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def __init__(
kwargs: dict[str, Any],
hide_help: bool,
section: str | None,
metavar: str,
metavar: str | None,
) -> None:
super().__init__(
flags=flags, arg_help=arg_help, hide_help=hide_help, section=section
Expand Down
3 changes: 0 additions & 3 deletions pylint/lint/report_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@

import collections
from collections import defaultdict
from typing import cast

from pylint import checkers, exceptions
from pylint.reporters.ureports.nodes import Section, Table
from pylint.typing import MessageTypesFullName
from pylint.utils import LinterStats


Expand Down Expand Up @@ -56,7 +54,6 @@ def report_messages_by_module_stats(
raise exceptions.EmptyReportError()
by_mod: defaultdict[str, dict[str, int | float]] = collections.defaultdict(dict)
for m_type in ("fatal", "error", "warning", "refactor", "convention"):
m_type = cast(MessageTypesFullName, m_type)
total = stats.get_global_message_count(m_type)
for module in module_stats.keys():
mod_total = stats.get_module_message_count(module, m_type)
Expand Down
2 changes: 1 addition & 1 deletion pylint/reporters/json_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def serialize_stats(self) -> dict[str, str | int | dict[str, int]]:
except Exception as ex: # pylint: disable=broad-except
score: str | int = f"An exception occurred while rating: {ex}"
else:
score = round(note, 2)
score = note

return {
"messageTypeCount": counts_dict,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_self.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ def test_modify_sys_path() -> None:
sys.path = copy(paths)
with _test_environ_pythonpath("/custom_pythonpath:"):
modify_sys_path()
assert sys.path == [paths[1]] + paths[3:]
assert sys.path == [paths[1], *paths[3:]]

paths = ["", cwd, "/custom_pythonpath", *default_paths]
sys.path = copy(paths)
Expand Down
Loading