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 DeprecationWarning #865

Merged
merged 11 commits into from
Jan 29, 2024
Merged

Conversation

ericdasse-stonal
Copy link
Contributor

@ericdasse-stonal ericdasse-stonal commented Dec 22, 2023

datetime.datetime.utcnow has been deprecated by Python and will soon be removed by Python 3.14 (see warning text below)

Besides, this warning pops up everytime someone with a recent version of Python (3.12+) uses this plugin, which makes the testing experience uncomfortable. I thus thought this contribution would be nice

.venv/lib/python3.12/site-packages/pytest_postgresql/retry.py:22: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
    time: datetime = datetime.utcnow()

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

Chore that needs to be done:

  • Add newsfragment pipenv run towncrier create [issue_number].[type].rst

Types are defined in the pyproject.toml, issue_numer either from issue tracker or the Pull request number

`datetime.datetime.utcnow` has been deprecated by Python and will soon be removed by Python 3.14

Besides, users of this plugin have lots of warning during their tests because of that which make testing experience uncomfortable. I thus thought that contribution would be nice
@codecov-commenter
Copy link

codecov-commenter commented Jan 2, 2024

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (bd79d0c) 95.45% compared to head (e8808ca) 91.02%.
Report is 4 commits behind head on main.

Files Patch % Lines
pytest_postgresql/retry.py 77.77% 2 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #865      +/-   ##
==========================================
- Coverage   95.45%   91.02%   -4.44%     
==========================================
  Files          13       13              
  Lines         396      401       +5     
==========================================
- Hits          378      365      -13     
- Misses         18       36      +18     
Flag Coverage Δ
unittests 91.02% <77.77%> (-4.44%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Collaborator

@fizyk fizyk left a comment

Choose a reason for hiding this comment

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

And a newsfragment will be needed

@@ -19,7 +19,7 @@ def retry(
... ::
FATAL: the database system is starting up
"""
time: datetime = datetime.utcnow()
time: datetime = datetime.now(UTC)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This change is not compatible with python 3.8 (eol at October 2024), 3.9 (eol at October 2025) and 3.10 (eol at October 2026).
I'd want to have some compatibility layer for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright! Thank you for your feedback. I will implement a compatibility layer for that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@fizyk fizyk added enhancement python Pull requests that update Python code labels Jan 12, 2024
@fizyk
Copy link
Collaborator

fizyk commented Jan 29, 2024

@ericdasse-stonal could you add newsfragment with description as well?

@ericdasse-stonal
Copy link
Contributor Author

@ericdasse-stonal could you add newsfragment with description as well?

Sure. To do that, do I need to create an issue first?

@fizyk
Copy link
Collaborator

fizyk commented Jan 29, 2024

No need, you can refer to this pr number as well

@ericdasse-stonal
Copy link
Contributor Author

No need, you can refer to this pr number as well

Alright. I took care of it

@fizyk fizyk merged commit 6843774 into dbfixtures:main Jan 29, 2024
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement python Pull requests that update Python code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants