Repository navigation
Fix importing dateparser_data.settings before dateparser - #1562
Merged
serhii73 merged 1 commit intoNov 4, 2026
Merged
Conversation
from dateparser_data.settings import default_parsers, the import shown in the documentation, raised AttributeError when it was the first import in the process: dateparser_data/settings.py imported dateparser._parts_of_day, which made it import the dateparser package, which reads settings.settings back while that module was still being executed. Add the PARTS_OF_DAY default where the settings module is read instead, so that dateparser_data.settings no longer imports dateparser, and test the import in a fresh interpreter. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Codecov Reportβ
All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1562 +/- ##
=======================================
Coverage 99.19% 99.19%
=======================================
Files 239 239
Lines 4098 4099 +1
=======================================
+ Hits 4065 4066 +1
Misses 33 33 β View full report in Codecov by Harness. π New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
from dateparser_data.settings import default_parsers, the import shown in the settings documentation, raisesAttributeError: partially initialized module 'dateparser_data.settings' has no attribute 'settings' (most likely due to a circular import)when it is the first import of the process. It works in 1.4.3 and whendateparseris imported first, which is why the test suite does not notice.Since #1473,
dateparser_data/settings.pyimportsdateparser._parts_of_day, which makes it import thedateparserpackage, which readssettings.settingsback while that module is still being executed.This adds the
PARTS_OF_DAYdefault where the module is read (Settings._get_settings_from_pyfile) instead, so thatdateparser_data.settingsno longer importsdateparser.Settingsadds the default to the module's dictionary when it first reads it; nothing else in the package or the docs reads that key from the module.The new test imports the module in a fresh interpreter, because in the test process
dateparseris always imported already. It fails without the change and passes with it.Checked with a local mirror of the CI matrix (16 legs): Python 3.10 to 3.15 (3.13 also with
TZ=Pacific/AucklandandTZ=Pacific/Fiji), the minimum supported dependency versions (with and without the optional ones), all optional dependencies, mypy, the docs build, the scripts, the benchmarks,twine checkand the pinned pre-commit hooks. All pass.π€ Generated with Claude Code