Skip to content

Commit d4ef72c

Browse files
[mypy] Fix all 'Redundant cast to Literal' fixed in new mypy version
1 parent 31cf98e commit d4ef72c

File tree

3 files changed

+1
-6
lines changed

3 files changed

+1
-6
lines changed

pylint/checkers/base/basic_checker.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ def report_by_type_stats(
7070
# percentage of different types documented and/or with a bad name
7171
nice_stats: dict[str, dict[str, str]] = {}
7272
for node_type in ("module", "class", "method", "function"):
73-
node_type = cast(Literal["function", "class", "method", "module"], node_type)
7473
total = stats.get_node_count(node_type)
7574
nice_stats[node_type] = {}
7675
if total != 0:

pylint/checkers/raw_metrics.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from __future__ import annotations
66

77
import tokenize
8-
from typing import TYPE_CHECKING, Any, Literal, cast
8+
from typing import TYPE_CHECKING, Any, Literal
99

1010
from pylint.checkers import BaseTokenChecker
1111
from pylint.reporters.ureports.nodes import Paragraph, Section, Table, Text
@@ -25,7 +25,6 @@ def report_raw_stats(
2525
sect.insert(0, Paragraph([Text(f"{total_lines} lines have been analyzed\n")]))
2626
lines = ["type", "number", "%", "previous", "difference"]
2727
for node_type in ("code", "docstring", "comment", "empty"):
28-
node_type = cast(Literal["code", "docstring", "comment", "empty"], node_type)
2928
total = stats.code_type_count[node_type]
3029
percent = float(total * 100) / total_lines if total_lines else None
3130
old = old_stats.code_type_count[node_type] if old_stats else None

pylint/lint/report_functions.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66

77
import collections
88
from collections import defaultdict
9-
from typing import cast
109

1110
from pylint import checkers, exceptions
1211
from pylint.reporters.ureports.nodes import Section, Table
13-
from pylint.typing import MessageTypesFullName
1412
from pylint.utils import LinterStats
1513

1614

@@ -56,7 +54,6 @@ def report_messages_by_module_stats(
5654
raise exceptions.EmptyReportError()
5755
by_mod: defaultdict[str, dict[str, int | float]] = collections.defaultdict(dict)
5856
for m_type in ("fatal", "error", "warning", "refactor", "convention"):
59-
m_type = cast(MessageTypesFullName, m_type)
6057
total = stats.get_global_message_count(m_type)
6158
for module in module_stats.keys():
6259
mod_total = stats.get_module_message_count(module, m_type)

0 commit comments

Comments
 (0)