"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pylint/message/message_id_store.py" between
pylint-2.14.1.tar.gz and pylint-2.14.2.tar.gz

About: pylint analyzes Python source code looking for bugs and signs of poor quality.

message_id_store.py  (pylint-2.14.1):message_id_store.py  (pylint-2.14.2)
skipping to change at line 12 skipping to change at line 12
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE # For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt # Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
from __future__ import annotations from __future__ import annotations
from typing import NoReturn from typing import NoReturn
from pylint.exceptions import ( from pylint.exceptions import (
DeletedMessageError, DeletedMessageError,
InvalidMessageError, InvalidMessageError,
MessageBecameExtensionError,
UnknownMessageError, UnknownMessageError,
) )
from pylint.message._deleted_message_ids import is_deleted_msgid, is_deleted_sym from pylint.message._deleted_message_ids import (
bol is_deleted_msgid,
is_deleted_symbol,
is_moved_msgid,
is_moved_symbol,
)
class MessageIdStore: class MessageIdStore:
"""The MessageIdStore store MessageId and make sure that there is a 1-1 rela tion """The MessageIdStore store MessageId and make sure that there is a 1-1 rela tion
between msgid and symbol. between msgid and symbol.
""" """
def __init__(self) -> None: def __init__(self) -> None:
self.__msgid_to_symbol: dict[str, str] = {} self.__msgid_to_symbol: dict[str, str] = {}
self.__symbol_to_msgid: dict[str, str] = {} self.__symbol_to_msgid: dict[str, str] = {}
skipping to change at line 130 skipping to change at line 136
self.__active_msgids is used to implement a primitive cache for this fun ction. self.__active_msgids is used to implement a primitive cache for this fun ction.
""" """
try: try:
return self.__active_msgids[msgid_or_symbol] return self.__active_msgids[msgid_or_symbol]
except KeyError: except KeyError:
pass pass
# If we don't have a cached value yet we compute it # If we don't have a cached value yet we compute it
msgid: str | None msgid: str | None
deletion_reason = None deletion_reason = None
moved_reason = None
if msgid_or_symbol[1:].isdigit(): if msgid_or_symbol[1:].isdigit():
# Only msgid can have a digit as second letter # Only msgid can have a digit as second letter
msgid = msgid_or_symbol.upper() msgid = msgid_or_symbol.upper()
symbol = self.__msgid_to_symbol.get(msgid) symbol = self.__msgid_to_symbol.get(msgid)
if not symbol: if not symbol:
deletion_reason = is_deleted_msgid(msgid) deletion_reason = is_deleted_msgid(msgid)
if deletion_reason is None:
moved_reason = is_moved_msgid(msgid)
else: else:
symbol = msgid_or_symbol symbol = msgid_or_symbol
msgid = self.__symbol_to_msgid.get(msgid_or_symbol) msgid = self.__symbol_to_msgid.get(msgid_or_symbol)
if not msgid: if not msgid:
deletion_reason = is_deleted_symbol(symbol) deletion_reason = is_deleted_symbol(symbol)
if deletion_reason is None:
moved_reason = is_moved_symbol(symbol)
if not msgid or not symbol: if not msgid or not symbol:
if deletion_reason is not None: if deletion_reason is not None:
raise DeletedMessageError(msgid_or_symbol, deletion_reason) raise DeletedMessageError(msgid_or_symbol, deletion_reason)
if moved_reason is not None:
raise MessageBecameExtensionError(msgid_or_symbol, moved_reason)
error_msg = f"No such message id or symbol '{msgid_or_symbol}'." error_msg = f"No such message id or symbol '{msgid_or_symbol}'."
raise UnknownMessageError(error_msg) raise UnknownMessageError(error_msg)
ids = self.__old_names.get(msgid, [msgid]) ids = self.__old_names.get(msgid, [msgid])
# Add to cache # Add to cache
self.__active_msgids[msgid_or_symbol] = ids self.__active_msgids[msgid_or_symbol] = ids
return ids return ids
 End of changes. 6 change blocks. 
2 lines changed or deleted 14 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)