From 0005c85fccccb491930f064ea8d064e87ce7ee79 Mon Sep 17 00:00:00 2001 From: "Tomas R." Date: Sun, 10 Nov 2024 21:39:04 +0100 Subject: [PATCH] Replace OrderedDict with just dict (#1149) --- babel/messages/catalog.py | 7 +++---- babel/messages/frontend.py | 2 -- babel/util.py | 3 +-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/babel/messages/catalog.py b/babel/messages/catalog.py index ecf6f91d4..cff22f9b5 100644 --- a/babel/messages/catalog.py +++ b/babel/messages/catalog.py @@ -11,7 +11,6 @@ import datetime import re -from collections import OrderedDict from collections.abc import Iterable, Iterator from copy import copy from difflib import SequenceMatcher @@ -317,7 +316,7 @@ def __init__( self.domain = domain self.locale = locale self._header_comment = header_comment - self._messages: OrderedDict[str | tuple[str, str], Message] = OrderedDict() + self._messages: dict[str | tuple[str, str], Message] = {} self.project = project or 'PROJECT' self.version = version or 'VERSION' @@ -344,7 +343,7 @@ def __init__( self.fuzzy = fuzzy # Dictionary of obsolete messages - self.obsolete: OrderedDict[str | tuple[str, str], Message] = OrderedDict() + self.obsolete: dict[str | tuple[str, str], Message] = {} self._num_plurals = None self._plural_expr = None @@ -829,7 +828,7 @@ def update( """ messages = self._messages remaining = messages.copy() - self._messages = OrderedDict() + self._messages = {} # Prepare for fuzzy matching fuzzy_candidates = {} diff --git a/babel/messages/frontend.py b/babel/messages/frontend.py index 7a9ce385f..9017ec5a8 100644 --- a/babel/messages/frontend.py +++ b/babel/messages/frontend.py @@ -20,7 +20,6 @@ import sys import tempfile import warnings -from collections import OrderedDict from configparser import RawConfigParser from io import StringIO from typing import BinaryIO, Iterable, Literal @@ -1019,7 +1018,6 @@ def parse_mapping_cfg(fileobj, filename=None): options_map = {} parser = RawConfigParser() - parser._sections = OrderedDict(parser._sections) # We need ordered sections parser.read_file(fileobj, filename) for section in parser.sections(): diff --git a/babel/util.py b/babel/util.py index db82d7361..180afa093 100644 --- a/babel/util.py +++ b/babel/util.py @@ -10,7 +10,6 @@ from __future__ import annotations import codecs -import collections import datetime import os import re @@ -231,7 +230,7 @@ def wraptext(text: str, width: int = 70, initial_indent: str = '', subsequent_in # TODO (Babel 3.x): Remove this re-export -odict = collections.OrderedDict +odict = dict class FixedOffsetTimezone(datetime.tzinfo):