summaryrefslogtreecommitdiff
path: root/pylint/utils/file_state.py
diff options
context:
space:
mode:
Diffstat (limited to 'pylint/utils/file_state.py')
-rw-r--r--pylint/utils/file_state.py54
1 files changed, 5 insertions, 49 deletions
diff --git a/pylint/utils/file_state.py b/pylint/utils/file_state.py
index 19122b373..9ae5fb077 100644
--- a/pylint/utils/file_state.py
+++ b/pylint/utils/file_state.py
@@ -1,15 +1,13 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
-# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
from __future__ import annotations
import collections
-import sys
-import warnings
from collections import defaultdict
from collections.abc import Iterator
-from typing import TYPE_CHECKING, Dict
+from typing import TYPE_CHECKING, Dict, Literal
from astroid import nodes
@@ -19,11 +17,6 @@ from pylint.constants import (
WarningScope,
)
-if sys.version_info >= (3, 8):
- from typing import Literal
-else:
- from typing_extensions import Literal
-
if TYPE_CHECKING:
from pylint.message import MessageDefinition, MessageDefinitionStore
@@ -36,26 +29,12 @@ class FileState:
def __init__(
self,
- modname: str | None = None,
- msg_store: MessageDefinitionStore | None = None,
+ modname: str,
+ msg_store: MessageDefinitionStore,
node: nodes.Module | None = None,
*,
is_base_filestate: bool = False,
) -> None:
- if modname is None:
- warnings.warn(
- "FileState needs a string as modname argument. "
- "This argument will be required in pylint 3.0",
- DeprecationWarning,
- stacklevel=2,
- )
- if msg_store is None:
- warnings.warn(
- "FileState needs a 'MessageDefinitionStore' as msg_store argument. "
- "This argument will be required in pylint 3.0",
- DeprecationWarning,
- stacklevel=2,
- )
self.base_name = modname
self._module_msgs_state: MessageStateDict = {}
self._raw_module_msgs_state: MessageStateDict = {}
@@ -74,25 +53,6 @@ class FileState:
PyLinter.
"""
- def collect_block_lines(
- self, msgs_store: MessageDefinitionStore, module_node: nodes.Module
- ) -> None:
- """Walk the AST to collect block level options line numbers."""
- warnings.warn(
- "'collect_block_lines' has been deprecated and will be removed in pylint 3.0.",
- DeprecationWarning,
- stacklevel=2,
- )
- for msg, lines in self._module_msgs_state.items():
- self._raw_module_msgs_state[msg] = lines.copy()
- orig_state = self._module_msgs_state.copy()
- self._module_msgs_state = {}
- self._suppression_mapping = {}
- self._effective_max_line_number = module_node.tolineno
- for msgid, lines in orig_state.items():
- for msgdef in msgs_store.get_message_definitions(msgid):
- self._set_state_on_block_lines(msgs_store, module_node, msgdef, lines)
-
def _set_state_on_block_lines(
self,
msgs_store: MessageDefinitionStore,
@@ -230,10 +190,6 @@ class FileState:
) -> None:
"""Set status (enabled/disable) for a given message at a given line."""
assert line > 0
- assert self._module
- # TODO: 3.0: Remove unnecessary assertion
- assert self._msgs_store
-
if scope != "line":
# Expand the status to cover all relevant block lines
self._set_state_on_block_lines(