Skip to content

Replace internal OrderedDict usage with dict#1328

Open
serhii73 wants to merge 1 commit into
masterfrom
fix/1108
Open

Replace internal OrderedDict usage with dict#1328
serhii73 wants to merge 1 commit into
masterfrom
fix/1108

Conversation

@serhii73
Copy link
Copy Markdown
Collaborator

@serhii73 serhii73 commented May 5, 2026

Close #1108

@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.10%. Comparing base (373ede9) to head (e1b172a).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1328      +/-   ##
==========================================
- Coverage   97.10%   97.10%   -0.01%     
==========================================
  Files         235      235              
  Lines        2904     2899       -5     
==========================================
- Hits         2820     2815       -5     
  Misses         84       84              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@serhii73 serhii73 requested review from AdrianAtZyte and wRAR May 5, 2026 14:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to modernize the codebase by replacing OrderedDict with plain dict now that supported Python versions preserve insertion order. It touches runtime parsing/loading code, calendar/localization helpers, data-generation scripts, and one ordering-sensitive test, in the context of issue #1108.

Changes:

  • Replaces several internal OrderedDict constructions with {}/dict(...) in parser, locale, loader, and date-handling code.
  • Updates Jalali calendar metadata and locale-relative translation helpers to use plain dicts.
  • Updates CLDR/supplementary data generation scripts and one date parsing test to remove OrderedDict.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/test_date.py Rewrites an ordering-sensitive test fixture from OrderedDict to dict.
dateparser/utils/__init__.py Changes combine_dicts() to build a plain dict.
dateparser/parser.py Replaces directive order containers with plain dicts.
dateparser/languages/locale.py Replaces relative-translation map construction with a plain dict.
dateparser/languages/loader.py Replaces locale maps with plain dicts, including get_locale_map().
dateparser/date.py Changes DateDataParser.previous_locales storage to a plain dict.
dateparser/calendars/jalali_parser.py Replaces ordered month/weekday maps with dict literals.
dateparser_scripts/write_complete_data.py Removes OrderedDict from generated-data assembly and file loading.
dateparser_scripts/utils.py Replaces script-side dict merge/diff helpers with plain dicts.
dateparser_scripts/order_languages.py Builds the language-locale output map with a plain dict.
dateparser_scripts/get_cldr_data.py Replaces ordered mappings in CLDR extraction/cleanup with plain dicts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

:return: ordered locale code to locale instance mapping
"""
return OrderedDict(
return dict(

def combine_dicts(primary_dict, supplementary_dict):
combined_dict = OrderedDict()
combined_dict = {}
Copy link
Copy Markdown
Contributor

@AdrianAtZyte AdrianAtZyte May 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clean, backward-compatible way to approach this is probably to create a special OrderedDict subclass that triggers a warning whenever such methods are used, and after a deprecation period of ~1 year, to start returning a dict instead.

Another approach would be to deprecate the function itself, and implement a new copy of it that uses dict instead of OrderedDict. If this method should not have been a public method in the first place, implementing a _combine_dicts function that uses dict and deprecating the public one is probably the simplest approach.

Comment thread dateparser/date.py
self.region = region
self.detect_languages_function = detect_languages_function
self.previous_locales = collections.OrderedDict()
self.previous_locales = {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace OrderedDict to dict

3 participants