Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PytzUsageWarning for Python versions >= 3.6 #1062



Copy link

@ismaildawoodjee ismaildawoodjee commented Jun 10, 2022

This fix makes the localize method to be used only for Python versions that are lower than 3.6, so that the warning doesn't appear for versions 3.6+. This also allows compatibility with Python 3.5.

Referencing Issue #1013 and implemented suggestions by @DavidMStraub and @bsekiewicz

  • Codecov report pending
  • Test cases passed with tox and tox -e py

* This fix makes the `localize` method to be used only for Python versions
that are lower than 3.6, so that the warning doesn't appear for versions 3.6+

* This also allows compatibility with Python 3.5
Copy link

codecov bot commented Jun 18, 2022

Codecov Report

Merging #1062 (b02015a) into master (89b7fda) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #1062   +/-   ##
  Coverage   98.29%   98.29%           
  Files         234      234           
  Lines        2694     2695    +1     
+ Hits         2648     2649    +1     
  Misses         46       46           
Impacted Files Coverage Δ
dateparser/ 93.93% <100.00%> (+0.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 89b7fda...b02015a. Read the comment docs.

@Gallaecio Gallaecio merged commit 0ed979e into scrapinghub:master Jun 20, 2022
10 checks passed
Copy link


Copy link

flapili commented Aug 12, 2022

still got the warning:

Python 3.10.4 (v3.10.4:9d38120e33, Mar 23 2022, 17:29:05) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dateparser
>>> dateparser.parse("1er juin")
/Users/xxxxx/Documents/xxx/xxxx/.venv/lib/python3.10/site-packages/dateparser/ PytzUsageWarning: The localize method is no longer necessary, as this time zone supports the fold attribute (PEP 495). For more details on migrating to a PEP 495-compliant implementation, see
  date_obj = stz.localize(date_obj)
datetime.datetime(2022, 6, 1, 0, 0)

Copy link

There is no dateparser release with the fix yet. If you install from the main Git branch, you should not get it.

Copy link

andydoc commented Oct 17, 2022

utils/ has the same problem at line 129
it is also possible that line 27 in needs similar amendment, but my current use case dose not get there

Copy link

Pugio commented Oct 27, 2022 also needs the same kind of change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

6 participants