Skip to content

Replace internal OrderedDict usage with dict - #1328

Merged
AdrianAtZyte merged 2 commits into
masterfrom
fix/1108
Jun 4, 2026
Merged

AdrianAtZyte merged 2 commits into
masterfrom
fix/1108

Conversation

@serhii73

@serhii73 serhii73 commented May 5, 2026 •

Copy link
Copy Markdown
Collaborator

Close #1108

@codecov

codecov Bot commented May 5, 2026 •

Copy link
Copy Markdown

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 97.11%. Comparing base (373ede9) to head (0e60216).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1328   +/-   ##
=======================================
  Coverage   97.10%   97.11%           
=======================================
  Files         235      235           
  Lines        2904     2912    +8     
=======================================
+ Hits         2820     2828    +8     
  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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread dateparser/languages/loader.py Outdated
:return: ordered locale code to locale instance mapping
"""
return OrderedDict(
return dict(
Comment thread dateparser/utils/__init__.py Outdated

def combine_dicts(primary_dict, supplementary_dict):
combined_dict = OrderedDict()
combined_dict = {}

@AdrianAtZyte AdrianAtZyte May 12, 2026 •

Copy link
Copy Markdown
Member

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 Resolved
get_locale_map(), dateparser.utils.combine_dicts(), and DateDataParser.previous_locales
are part of the observable API, so swapping their type to plain dict would be a
breaking change. Limit the OrderedDict->dict replacement to purely internal usages
per issue #1108 scope and reviewer feedback.
@AdrianAtZyte
AdrianAtZyte merged commit b107ac3 into master Jun 4, 2026
18 checks passed
@serhii73 serhii73 mentioned this pull request Jun 15, 2026
@serhii73
serhii73 deleted the fix/1108 branch June 22, 2026 10:48
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