Fix PytzUsageWarning for Python versions >= 3.6#1062
Merged
Gallaecio merged 1 commit intoscrapinghub:masterfrom Jun 20, 2022
Merged
Fix PytzUsageWarning for Python versions >= 3.6#1062Gallaecio merged 1 commit intoscrapinghub:masterfrom
Gallaecio merged 1 commit intoscrapinghub:masterfrom
Conversation
* 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
Codecov Report
@@ Coverage Diff @@
## master #1062 +/- ##
=======================================
Coverage 98.29% 98.29%
=======================================
Files 234 234
Lines 2694 2695 +1
=======================================
+ Hits 2648 2649 +1
Misses 46 46
Continue to review full report at Codecov.
|
gutsytechster
approved these changes
Jun 18, 2022
Gallaecio
approved these changes
Jun 20, 2022
Contributor
|
Thanks! |
This was referenced Jun 22, 2022
Closed
|
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/date_parser.py:35: 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 https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html
date_obj = stz.localize(date_obj)
datetime.datetime(2022, 6, 1, 0, 0) |
Contributor
|
There is no dateparser release with the fix yet. If you install from the main Git branch, you should not get it. |
|
|
|
freshness_date_parser.py:76 also needs the same kind of change. |
Merged
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.
This fix makes the
localizemethod 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
toxandtox -e py